SSH CONNECTIONS WITHOUT PASSWORD

How to connect by ssh without password

SSH is a protocol of safe connection by terminal between two machines with the demon or active service ssh almenos in one of them. Daemon SSH works listening to requests in port 22, and although the technologies in certain way have advanced much, this protocol continues being quite safe, effective and sometimes we required of its use to carry out connections to our server by different reasons.
ssh

The SSH connections can be:

  • SSH SERVANT (sshd) €“ SSH CLIENT (ssh)
  • SSH SERVANT (sshd) €“ SSH SERVANT (sshd)

We imagine that we have a machine 1 with the IP 192.168.1.20 and machine 2 with the IP 192.168.1.50, our objective is that the machine I number 1 can connect when it wants with machine 2 without needing introducing password (for example to create scripts with SSH commandos and to execute them in the CRON of programmed form, for backups or any similar action).

    • We are in machine 1: 192.168.1.20

We enter machine 1 and in his terminal we executed:

SSH-keygen - b 4096 - t rsa

With this commando we are generating the public and deprived pair of keys RSA, with which we will verify in the remote servant that we are.


      Now we copied and we sent this public key to machine 2, executing this commando within the same terminal in which we were (root or the user that is, and the IP of the machine that we want to accede):

 

SSH-Copy-you go root@192.168.1.50

Next (192.168.1.50) will request password to us of the machine 2, and with this it is created the relacci³n of confidence between both machines.


      Now we can be connected whenever we want without needing introducing password:

 

ssh root@192.168.1.50

With this configuration we will be able to create scripts with nested SSH commandos with MYSQL, SCP or others. This way and programming them in the CRON of the machine we will have a field opened to our imagination: Basic copies of data, Copies of directories FTP€¦ and hundreds of ideas more.

I hope that this article serves to you as help,
A greeting,
Oscar/Devservice.es

Whitechsolutions
By “scar Carrillo