Skip to content

Instantly share code, notes, and snippets.

@generalistcodes
Created March 29, 2016 15:06
Show Gist options
  • Save generalistcodes/46749be96b3eae264953 to your computer and use it in GitHub Desktop.
Save generalistcodes/46749be96b3eae264953 to your computer and use it in GitHub Desktop.

Add Public SSH Key to Remote Server in a Single Command

If you want to setup SSH keys to allow logging in without a password, you can do so with a single command.

The first thing you’ll need to do is make sure you’ve run the keygen command to generate the keys:

$ ssh-keygen -t rsa

Then use this command to push the key to the remote server, modifying it to match your server name.

cat ~/.ssh/id_rsa.pub | ssh root@hostname 'cat >> .ssh/authorized_keys'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment