Ubuntu - Sharing SSH Keys

Sharing keys on Ubuntu is as easy as:

ssh-copy-id user@hostname.domain.com

If you want to use a specific key, then use the following

ssh-copy-id -i [PUBLIC KEY FILE] user@hostname.domain.com

If you don't already have an identity, an error will pop up and you will need to run the following before retrying.


This grants yourself non-password access to the remote machine, not the other way around!

Always use a passphrase on your keys to prevent them being useful to malicious users who compromise your servers. Tools like ansible will realize if a key requires a passphrase to use and will automatically prompt you.




Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus