SSH password less login
In this blog I am going to explain how to login to a linux machine through ssh with out password.
SSH password less login is one of the good feature of secure shell (ssh) .If you are logging in to a remote machine many time every day via secure shell (ssh) then ssh password less login will save your time of entering password.
SSH password less login is one of the good feature of secure shell (ssh) .If you are logging in to a remote machine many time every day via secure shell (ssh) then ssh password less login will save your time of entering password.
Consider that there are two machines with IP address 192.168.1.8 and 192.168.1.9. I am using 192.168.1.8 machine with username rajkumar and I want to take 192.168.1.9 machine’s adminuser remotely via ssh without password.
Login to the remote machine 192.168.1.9 as adminuser
Yes you can see from the above image that it is asking for password while login.
Ok!! Let’s learn how to login to remote machine without password.
Step 1: Generate ssh-keygen from the specific user(rajkumar) login
su – rajkumar
ssh-keygen
ssh-keygen
If you give ssh-keygen it will ask you in which location rsa key should save give enter for that.
Then it will prompt for passphrase password simply give enter for that.
Then it will prompt for passphrase password simply give enter for that.
Step 2: Go to the user’s home directory and copy the id_rsa.pub to authorized_keys.
cd ~/.ssh
ls
cp id_rsa.pub authorized_keys
ls
cp id_rsa.pub authorized_keys
Step 3: Check .ssh folder is available on adminuser’s home directory
Important Steps:
=============
=============
Login in to remote machine as adminuser@192.168.1.9
cd /home/adminuser
ls -a
ls -a
Check .ssh folder is already available or not.If .ssh folder is not already available create it with ssh-keygen command.
ssh-keygen
ls -a
ls -a
If .ssh folder is already available continue with Step 4
Step 4: Copy the authorized_keys file to /home/adminuser/.ssh/ via scp
scp authorized_keys adminuser@192.168.1.9:/home/adminuser/.ssh/
Step 5: Login in to the remote machine with out password
ssh adminuser@192.168.1.9
If still not able to login with out password. login in to 192.168.1.9 machine as adminuser and follow the below steps
$ chmod go-w $HOME $HOME/.ssh
$ chmod 600 $HOME/.ssh/authorized_keys
$ chown `whoami` $HOME/.ssh/authorized_keys
$ chmod 600 $HOME/.ssh/authorized_keys
$ chown `whoami` $HOME/.ssh/authorized_keys
If still not able to login with out password. login in to 192.168.1.9 machine as root user and follow the below steps
use editor of your preference vi,nano and others
use editor of your preference vi,nano and others
vi /etc/ssh/sshd_config
StrictModes no
StrictModes no
Change StrictModes from “yes” to “no” and save the file. Restart the ssh service it will definitely work but changing StrictModes from “yes” to “no” is not recommended.
Share and Enjoy
thanks to thetechnicalstuff
Comments
Post a Comment