[Linux] How to configure a passwordless ssh
today we’re going to talk about a very useful configuration, that can help you with monitoring, deploying, etc… configuring a passwordless ssh.
First of all, you need to generate a pair of key: your public key and your private key.
$ ssh-keygen -t rsa
With this commande, you will generate 2 files and the path ~/.ssh: id_rsa and id_rsa.pub.
Now you’ve to create on your destination machine the directory .ssh.
$ ssh dest_user@dest_machine mkdir -p .ssh
Now, you’ve to copy the text inside the file id_rsa.pub in a file called authorized_keys under ~/.ssh of the destination machine:
$ cat .ssh/id_rsa.pub | ssh dest_user@dest_machine 'cat >> .ssh/authorized_keys'
Now you can try to connect to your remote machine, if it doesn’t ask you for a password, you’ve finished:
If it doesn’t work, you need to do this commands on your remote machine:
$ chmod go-w ~/
$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/authorized_keys
Now your passwordless ssh is finally working and you don’t need anymore to remember a lot of password!