SSH Keyless Authentication

 SSH Keyless Authentication:

To check If SSH is installed
Host 1:
[root@localhost ~]# rpm -qa openssh*
openssh-server-5.3p1-52.el6.i686
openssh-clients-5.3p1-52.el6.i686
openssh-5.3p1-52.el6.i686
openssh-askpass-5.3p1-52.el6.i686
[root@localhost ~]#

Host 2(Remote Host):
[avk@masterdns ~]$ rpm -qa openssh*
openssh-server-5.3p1-52.el6.i686
openssh-clients-5.3p1-52.el6.i686
openssh-5.3p1-52.el6.i686
openssh-askpass-5.3p1-52.el6.i686
[avk@masterdns ~]$

To install SSH

[root@localhost ~]# yum install openssh -y

To make SSH service on
[root@localhost ~]# chkconfig sshd on

To check SSH Service status:

[root@localhost ~]# service sshd status
openssh-daemon (pid 1992) is running…

To restart SSH service:

[root@localhost ~]# service sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
[root@localhost ~]#

Generate public/private rsa key pair:

[root@localhost ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory ‘/root/.ssh’.
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:
1b:0e:02:ad:91:a4:fb:79:55:33:0a:9b:ff:f3:0a:aa root@localhost.localdomain
The key’s randomart image is:
+–[ RSA 2048]—-+
| . |
| o o |
|. + o + |
| . + + o o |
|. . + + S |
| . . + o o |
| o . o o |
| . . o. |
| E.. o+. |
+—————–+
[root@localhost ~]#

Login to Remote Host:

[root@localhost ~]# ssh avk@192.168.211.134
The authenticity of host ‘192.168.211.134 (192.168.211.134)’ can’t be established.
RSA key fingerprint is 06:1c:03:81:74:95:54:54:ec:66:30:5d:d7:35:94:90.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.211.134’ (RSA) to the list of known hosts.
avk@192.168.211.134’s password:

[avk@masterdns ~]$ exit
logout
Connection to 192.168.211.134 closed.

Copying SSH_ID on remote host

[root@localhost ~]# ssh-copy-id avk@192.168.211.134
avk@192.168.211.134’s password:
Now try logging into the machine, with “ssh ‘avk@192.168.211.134′”, and check in:

.ssh/authorized_keys

to make sure we haven’t added extra keys that you weren’t expecting.

[root@localhost ~]#

SSH KEYLESS Authentication:

[root@localhost ~]# ssh avk@192.168.211.134
Last login: Wed Sep 6 13:29:06 2017 from 192.168.211.135
[avk@masterdns ~]$