How to copy SSH keys to a server securely

Jan 27, 2019

I much prefer SSH key authentication to password-based authentication when working with remote servers. One, it's one less password to remember. Two, on your machine, it's automatic. Three, it's more secure. So once you've got your server running, this is how you can copy your SSH key to it:

ssh-copy-id [email protected]_host

This will copy your default SSH key from ~/.ssh/id_rsa.pub to the server. If you'd like to copy a different key instead, you can specify it using the -i parameter, like so:

ssh-copy-id -i ~/.ssh/mykey [email protected]_host

And that's it! Your SSH key has been copied to your server securely!

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.