Setup SSH login to don't ask password again

Feb 14, 2017

If you use the SSH a lot of time or want to sync files, probably you need to type your password many times a day. The way to avoid this problem and create a free communication between two Linux computers is to share the public ssh key.

If you want to learn more about encryption and understand the differences between public and private keys, I recommend you the Teckquickie’s vídeo "Encryption as Fast As Possible".

On the step below, you will learn how to pass your computer public key to your server you want to access. So, every time you try to access your server again, it’ll know who are you and allow your connection without asking your password.

Server side

On your server, you will need to create an SSH private and public key. The command below will create both if not exists.

ssh-keygen -t rsa  

Just type the command above and press [Enter] until get bash cursor again as the image below:

Client side

Now, on your computer, you need to create SSH keys too. And after you need to pass you public RSA key from “~/.ssh/id_rsa.pub” to your server “~/.ssh/authorized_keys”. The second command below do this, just change the “root” user and type the correct IP you already use in common SSH access.

ssh-keygen -t rsa  
cat ~/.ssh/id_rsa.pub | ssh root@[your.ip.address.here] "cat >> ~/.ssh/authorized_keys"  

Now you can enter on your server without type the password!

Questions?

If you have any questions, just leave the comments below. I’ll try to help you as best I can. ^^

References

How To Use SSH Keys with DigitalOcean Droplets
https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets

Encryption as Fast As Possible
https://www.youtube.com/watch?v=dut9EnbFym0

Tags

Luiz Felipe F M Costa

I am a quality engineer at Red Hat / Ansible. I love automation tools, games, and coffee. I am also an active contributor to open-source projects on GitHub.