Tired of entering your password every time you login into your server through ssh? Well, all you have to do is generate a private/public key and copy your public key to the remote server. Here’s how!
1- Generate the key pair using ssh-keygen
jorge@nixlap ~$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: b0:70:53:4e:b2:bc:73:98:b6:b7:a9:48:68:a6:2c:0b root@nixlap The key's randomart image is: +--[ RSA 2048]----+ | . o | | . * | | . * . | | o B | | B S | | . . + | |E + . . . | |++ . . . o | |+o . ..o | +-----------------+ jorge@nixlap $
2- Create the .ssh directory in remote host. This usually exists if you’ve already logged in remotely.
ssh user@remotehost mkdir -p .ssh
3- Copy the key to remote .ssh directory
cat .ssh/id_rsa.pub | ssh user@remotehost 'cat >> .ssh/authorized_keys'
and you’re set, now you don’t have to enter your password when login remotely.