aws iam upload-ssh-public-key
Uploads an SSH public key and associates it with the specified IAM user. AWS CLI reference
1 example 2 options Its page in the AWS CLI reference
Examples
To upload an SSH public key and associate it with a user
The following upload-ssh-public-key example uploads the public key found in the file sshkey.pub and attaches it to the user sofia.
aws iam upload-ssh-public-key --user-name sofia --ssh-public-key-body file://sshkey.pubIdentify--user-nameThe name of the IAM user to associate the SSH public key with.--ssh-public-key-bodyThe SSH public key.Contents of sshkey.pub:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQEXAMPLE... sofia@example.com
Its output
{
"SSHPublicKey": {
"UserName": "sofia",
"SSHPublicKeyId": "APKA1234567890EXAMPLE",
"Fingerprint": "12:34:56:78:90:ab:cd:ef:12:34:56:78:90:ab:cd:ef",
"SSHPublicKeyBody": "ssh-rsa <<long string generated by ssh-keygen command>>",
"Status": "Active",
"UploadDate": "2019-04-18T17:04:49+00:00"
}
}For more information about how to generate keys in a format suitable for this command, see SSH and Linux, macOS, or Unix: Set up the public and private keys for Git and CodeCommit or SSH and Windows: Set up the public and private keys for Git and CodeCommit in the AWS CodeCommit User Guide.
Options
--ssh-public-key-bodyThe SSH public key.--user-nameThe name of the IAM user to associate the SSH public key with.