Thursday, October 27, 2016

Password Less SSH Between Centos

Password Less SSH Connection between Two Centos Server


Description

Here I have explained password less ssh configuration between two centos server. Please find below steps to configure it. Password less ssh configuration require when you want to upload backup using ssh.

Scenario:


Server 1: Source Server
Operating System: Centos 6
IP Address: 10.0.0.1

Server 2: Destination Server
Operating System: Centos 6
IP Address: 20.0.0.1

Procedure


  • Login to Server1 using root user
  • create the public key and private key by following command
# ssh-keygen -t rsa

  • It will ask for passphrase just press enter if you do not want to set any passphrase
  • After creating these keys you have to copy to the remote host [Server2] which you want to connect without password
  • Login to Server2 remote host.
  • Check .ssh directory is there or not by locate .ssh command
  • If .ssh directory is not there than create the directory by mkdir /root/.ssh
  • Give permission to .ssh directory using below command
# chmod 700 .ssh

  • Restart ssh service in Server2 using below command
# /etc/init.d/ssh restart

  • Come back to  Server1 and copy the key to the remote server [Server2] by following command
# cat id_rsa.pub | ssh -p 2220 root@20.0.0.1 'cat >>.ssh/authorized_keys'

Note: - You have to enter this command if port is different from 22 otherwise you can just follow the simple command
# ssh-copy-id  root@20.0.0.1

  • After that you can check the ssh login to the remote server [Server2]
# ssh –p 2220 root@20.0.0.1

  • It will not prompt you for the password and directly you will get the prompt.


No comments:

Post a Comment