How to Generate SSH Keys for Passwordless SSHing

If you’re sick of typing in your password every time you SSH to the same remote server, you can generate SSH keys to avoid having to do it again.  This is also very handy for scp, rsync, and other protocols that rely on SSH and therefore prompt you for a password.

First, generate your keys.

ssh-keygen -t rsa

Then press enter three times. After that, transfer your new public key over to the remote server with this command:

cat ~/.ssh/ | ssh user@remoteserver 'cat >> .ssh/authorized_keys'

You’ll be prompted for your password when you run that command, but that will be the last time.