List
List the authorized SSH keys of a user.
Reads ~/.ssh/authorized_keys of the user through gohai, with the type, the SHA256 fingerprint, the comment and the options of each key. A user with no file has no keys. A user that the host does not have is not found.
osapi client node user sshkey list [flags]
Examples
# A user with keys
osapi client node user sshkey list --target web-01 --name osapitest
# A user with no keys
osapi client node user sshkey list --target web-01 --name osapitest
# A host key that gohai cannot read
osapi client node user sshkey list --target web-01 --name osapitest
Result
A user with keys, on one host:
$ osapi client node user sshkey list --target web-01 --name osapitest Results: HOSTNAME STATUS TYPE FINGERPRINT COMMENT OPTIONS web-01 ok ssh-ed25519 SHA256:mnpIO1El26FsWnOeLzppADcNXgXRNHh9MPNPLPvSCwk osapitest@example web-01 ok ssh-ed25519 SHA256:a5CeY6Lh3ZXkJOqGyuwb24kQeVjgag1gc9ujzv++nhE other@example from="10.0.0.0/8" 1 host: 1 ok job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9
On each host, where one cannot run it:
$ osapi client node user sshkey list --target _all --name osapitest Results: HOSTNAME STATUS TYPE FINGERPRINT COMMENT OPTIONS web-01 ok ssh-ed25519 SHA256:mnpIO1El26FsWnOeLzppADcNXgXRNHh9MPNPLPvSCwk osapitest@example web-01 ok ssh-ed25519 SHA256:a5CeY6Lh3ZXkJOqGyuwb24kQeVjgag1gc9ujzv++nhE other@example from="10.0.0.0/8" web-02 ok ssh-ed25519 SHA256:mnpIO1El26FsWnOeLzppADcNXgXRNHh9MPNPLPvSCwk osapitest@example web-02 ok ssh-ed25519 SHA256:a5CeY6Lh3ZXkJOqGyuwb24kQeVjgag1gc9ujzv++nhE other@example from="10.0.0.0/8" 3 hosts: 2 ok, 1 skipped job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9 Details: mac-01 skipped operation not supported on this OS family
With --json, the API's response:
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"results": [
{
"comment": "osapitest@example",
"fingerprint": "SHA256:mnpIO1El26FsWnOeLzppADcNXgXRNHh9MPNPLPvSCwk",
"hostname": "web-01",
"status": "ok",
"type": "ssh-ed25519"
},
{
"comment": "other@example",
"fingerprint": "SHA256:a5CeY6Lh3ZXkJOqGyuwb24kQeVjgag1gc9ujzv++nhE",
"hostname": "web-01",
"options": "from=\"10.0.0.0/8\"",
"status": "ok",
"type": "ssh-ed25519"
}
]
}
A user with no keys, on one host:
$ osapi client node user sshkey list --target web-01 --name osapitest Results: None.
On each host, where one cannot run it:
$ osapi client node user sshkey list --target _all --name osapitest Results: 1 host: 1 skipped job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9 Details: mac-01 skipped operation not supported on this OS family
With --json, the API's response:
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"results": []
}
A host key that gohai cannot read, on one host:
$ osapi client node user sshkey list --target web-01 --name osapitest Results: HOSTNAME STATUS TYPE FINGERPRINT COMMENT OPTIONS web-01 ok ssh-ed25519 SHA256:mnpIO1El26FsWnOeLzppADcNXgXRNHh9MPNPLPvSCwk osapitest@example 1 host: 1 ok job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9
On each host, where one cannot run it:
$ osapi client node user sshkey list --target _all --name osapitest Results: HOSTNAME STATUS TYPE FINGERPRINT COMMENT OPTIONS web-01 ok ssh-ed25519 SHA256:mnpIO1El26FsWnOeLzppADcNXgXRNHh9MPNPLPvSCwk osapitest@example web-02 ok ssh-ed25519 SHA256:mnpIO1El26FsWnOeLzppADcNXgXRNHh9MPNPLPvSCwk osapitest@example 3 hosts: 2 ok, 1 skipped job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9 Details: mac-01 skipped operation not supported on this OS family
With --json, the API's response:
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"results": [
{
"comment": "osapitest@example",
"fingerprint": "SHA256:mnpIO1El26FsWnOeLzppADcNXgXRNHh9MPNPLPvSCwk",
"hostname": "web-01",
"status": "ok",
"type": "ssh-ed25519"
}
]
}
The command fails in these cases:
| Call | Flags | Fails with |
|---|---|---|
| A user that the host does not have | --name nobody | not found |
| A name that is not a user name | --name "Bad;name" | Name |
| A name over 32 characters | --name aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | max |
Permission
It needs the user:read permission. osapi controller role get --name <role>
shows what a role grants.
Flags
| Flag | Description | Default |
|---|---|---|
--name | The user, such as alice (required) | |
-T, --target | Target: _all, _any, hostname, or label (group:web.dev) | _all |
Global flags
| Flag | Description | Default |
|---|---|---|
-d, --debug | Enable or disable debug mode | |
-j, --json | Enable JSON output | |
-f, --osapi-file | Path to config file; without one at the default path, osapi runs on the defaults | /etc/osapi/osapi.yaml |
--url | Base URL the CLI client connects to (controller.client.url) | https://localhost:8080 |
Output tells how the result is printed, and what
--json gives.