Showing posts with label Login. Show all posts
Showing posts with label Login. Show all posts

Tuesday, October 17, 2017

SSH Password less Login Using SSH Keygen

To configure SSH Passwordless Login Using SSH Keygen.
Find My Scenario to configure.

SSH Client : 192.168.1.193 ( CentOS 7 )
SSH Remote Host : 192.168.1.47 ( CentOS 7 )
Step 1: Create Authentication SSH-Kegen Keys on – (192.168.1.193 – Client)

First login into server 192.168.1.193 with user root and generate a pair of public keys using following command.

[root@gcdc-nms opt]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/rsync_key
Enter passphrase (empty for no passphrase): [Hit Enter]
Enter same passphrase again: [Hit Enter]
Your identification has been saved in /root/.ssh/rsync_key.
Your public key has been saved in /root/.ssh/rsync_key.pub.
The key fingerprint is:
SHA256:9hAlaN2gBCOmbIVv4QcGOiMSZp9yIHcVFgeWvHizo/4 root@gcdc-nms.localdomain
The key's randomart image is:
+---[RSA 2048]----+
|o=*.++OB+o.      |
|**+*.==o.o.      |
|B+++oo...        |
|+oo+..+  .       |
|  . .. oS        |
|      o. o       |
|     . .  .      |
|    .            |
|   ...E          |
+----[SHA256]-----+


Step 2: Create .ssh Directory on – 192.168.1.47 (Server)

# ssh root@192.168.1.47 mkdir -p .ssh

Step 3: Upload Generated Public Keys to – 192.168.1.47 (Go to 192.168.1.193 – Client)

# cat .ssh/id_rsa.pub | ssh root@192.168.1.47 'cat >> .ssh/authorized_keys'

Step 4: Set Permissions on – 192.168.1.47 (Server)

# ssh root@192.168.1.47 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

Step 5: Login from 192.168.1.193 (Client) to 192.168.1.47 (Server) Server without Password

# ssh root@192.168.1.47

Enable SSH for root user on Ubuntu

To enable root Login, first assign the password for root user.

#sudo passwd root                -/enter new password for root user here.

Directly copy and paste this below lines in command prompt, to set ssh to allow root logins.

sed -i 's/Authentication:/#Authentication:/g' /etc/ssh/sshd_config sed -i 's/LoginGraceTime/#LoginGraceTime/g' /etc/ssh/sshd_config sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config sed -i 's/PermitRootLogin without-password/#PermitRootLogin without-password/g' /etc/ssh/sshd_config sed -i 's/StrictModes yes/#StrictModes yes' /etc/ssh/sshd_config service ssh restart

Or you can also configure it by manually by editing configuration file as mentioned below.

#vim /etc/ssh/sshd_config
# Authentication:
#LoginGraceTime 120
PermitRootLogin yes
#PermitRootLogin without-password
#StrictModes yes








Comment lines as mentioned above.

Save and exit the file.

Now restart ssh service

#service ssh restart

Check from the client machine.