SSH keys can provide an additional layer of security (if you also disable password authentication on the server), or they can simplify the process of connecting to remote servers. For our purposes we’re interested in the latter – connecting to the server without entering a password.
The basic idea is that you create a public/private key pair on your computer, then upload the public key to the remote server. When you connect to the remote server, your computer can use the private key to authenticate instead of entering your password.
First we’ll create the key:
ssh-keygen -f ~/.ssh/id_rsa -N ""
If a key already exists, you’ll be asked if you want to overwrite it. If this happens you can respond by pressing “n” (no) and continue to the next step.
Next we need to upload the key to the server. Replace “user” with your username, and “host” with the address of the SSH server.
ssh-copy-id -i ~/.ssh/id_rsa user@host
If it worked, you should now be able to SSH to the remote host without entering your password.