Hello, after some time of inactivity I've come to show the advantage of Linux servers or computers to communicate using SSH keys.
Scenario: I need using SCP to copy the backups that I get on my server1, to another with more space but I want to automate this process for which I create a cron to run the SCP, but fails to be automatic and not have who enter password of server2. Solution: Communication Keys thus avoiding having to enter password on these computers to SSH sessions.
We Need:
1. Server1 with SSH
2. SSH Server 2 with
NOTE: do not have to be servers, can also be computers that have installed the SSH Daemon. 1. In the Server1 create our public key:
# root @ server1: ssh-keygen-t rsa
Note: this we are asked to enter a phrase, do not enter anything because they do not want this request something at the time of login, so just We ENTER and ENTER again to confirm not enter anything, ready and our key was created, if this happened we left the default path "/ root / .ssh /" there will be placed our keys.
2. now we copy the key from server1 to the server2
root @ server1 #: scp-r / root / .ssh / id_rsa.pub root @ server2: / tmp
Note: the copy in the temporary server2 to follow the steps.
3.Now on server2 I think the file that will contain the Key
Server1 root @ server2 #: touch / root / .ssh / authorized_keys
4. Now copy the key into
file root @ server2 # cat / tmp / id_rsa.pub />> / root / .ssh / authorized_keys Well
alone with this since we loguearnos no password Server1 to Server2, and if we want these two to communicate without password what we do is repeat the steps in reverse.
hope they serve!
0 comments:
Post a Comment