...
If you’re looking to give users SSH access to an instance, you will need to append their SSH public key (which should start with “"ssh-rsa” " followed by a long string) to the file /home/ubuntu/.ssh/authorized_keys (make sure that you append to the file, DO NOT overwrite what is there already or you will lose access to the instance yourself).
To do this while logged in to the instance, you can simply append the public key to the authorized_keys file directly (e.g. nano ~/.ssh/authorized_keys then paste in the string of characters from the public key) or:
Code Block |
---|
cat id_rsa.pub >> ~/.ssh/authorized_keys |
Alternatively, if not logged into the instance you can run the following:
Code Block |
---|
ssh-copy-id -i <public_key_file_to_add> ubuntu@<ip_address_of_instance> |
Replace <public_key_file_to_add> with the filename of their public key file, and <ip_address_of_instance> with the IP address of your instance, for example:
Code Block |
---|
ssh-copy-id -i id_rsa.pub ubuntu@146.118.64.158 |
Replace ubuntu with centos in the examples above if your instance was created using one of the CentOS images.