Thursday 2 May 2013

SSH Configure without password on linux



On node01 :
  1. On the node01 server as root owner (do not enter passphrase!):
[root@node01 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
56:37:86:ac:0c:23:04:0a:e8:b9:e6:65:b3:36:09:cd root@node01
  1. This will generate 2 files under your home directory:
[root@node01 .ssh]# ls
id_rsa id_rsa.pub known_hosts
  1. You can see id_rsa.pub file contents
[root@node01 .ssh]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAv36oBd4kcS/sStXKgxECTzKVgSlqUiHzn78R4vESxscY W0RBUr2q2X49DEhnTRKmg4q94EwUlapL0+7cObX8IEWt9yPcZ0hTRVALrwGeC/D2hHQ2kRwVx5NIq+ey WO/Xp8/i8x1KCWezrGRI/5uaHhVm5u7cw0i4/jQR+0Ek9Ut6wF9hZIlLAJgEJtdpTdhEC3M1T2LHlkXn cmXe8ndFtDoLEoqDjM5+3mQu6cDjIZ/aLT88uejYDEv12x/tyN3ICRkuaYFaV7SDe4V/kpOOa3nEbf2Y e2Rx/B0ZmxZ01lvKn43hOZpK94Cuu6ZcKwRTEajvPIeRiSwChAOTBtvadw== root@node01
  1. Copy id_rsa.pub file to node02 server.
[root@node01 ~]# cd .ssh/
[root@node01 .ssh]# scp id_rsa.pub root@node02:/root
root@node02′s password:
id_rsa.pub 100% 393 0.4KB/s 00:00
  1. Connect to the node02 server
ot@node01 ~]# ssh node02
The authenticity of host ‘node02 (192.168.4.11)’ can’t be established.
RSA key fingerprint is d0:5d:7c:01:b2:a4:ef:41:ed:b9:98:89:60:46:1f:46.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘node02,192.168.4.11′ (RSA) to the list of known hosts.
root@node02′s password:
Last login: Fri Dec 23 19:42:34 2011 from 192.168.4.13
  1. Create empty authorized_keys file with touch command
[root@node02 .ssh]# touch authorized_keys
  1. Then append node01 id_rsa.pub contents to created authorized_keys file in node02.
[root@node02 ~]# cat id_rsa.pub >>~/.ssh/authorized_keys
[root@node02 ~]# cd ~/.ssh/
  1. It’s important to change file permission otherwise it’s not working.
[root@node02.ssh]# chmod 600 authorized_keys
On Node02 : Same thing do on node02
[root@node02 ~]# cd ~/.ssh
[root@node02 .ssh]# ls
known_hosts
[root@node02 .ssh]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
86:a8:d4:98:fa:1a:4f:cf:1d:f0:87:ac:eb:ac:41:a6 root@node02
[root@node02 .ssh]# ls
id_rsa id_rsa.pub known_hosts
[root@node02 .ssh]# scp id_rsa.pub root@node01:/root
root@node01′s password:
id_rsa.pub 100% 393 0.4KB/s 00:00
[root@node02 ~]# cat id_rsa.pub >> ~/.ssh/authorized_keys
[root@node01 ~]# ssh node02
Last login: Fri Dec 23 19:44:07 2011 from node01
[root@node02 ~]#
Congratulation you have done it sucessfully. Enjoy it

No comments:

Post a Comment

Install XRDP in Centos 7

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum update yum groupinstall "GNOME Desktop" ...