How to login to unix machines with out password using SSH ?
1. Your home directory
drwx------
2.Your ~/.ssh/authorized_keys should be ( chmod 600 )
3.SE linux can cause problem in some linux version , so you might need to disable it
1.
Windows to UNIX server
-
Create your private key using Putty ken gen
Click
on Generate, then drag the mouse the save the key as private key
-
Save the file as test.ppk
-
Log on to UNIX server
-
Cd .ssh ( under home dir )
-
Create new file authorized_keys or edit the file
-
Then add your private key their …. ( it is single line )
Example
: ssh-rsa
AAAAB3NzaC1yc2EAAAABJQAAAIEAklJzYkmTbFKi6xE9o1kYqEU3YS+iOmY6aNOPm2QmljbigiziqI6w+zrckBXiWvABtRdp712mrkTUPA7Idmss+0lWGRtHdgxxfDQsvJj5bpm56K/4Cw83nSvj3TdtvwUiri7X4sje12Qlr71iECqDZFwKayGTcK0M0bLuZY4C+a8=
rsa-key-20080102 - test
-
Also add test at the end of the line
-
Again open putty
-
Enter Hostname
-
Click on ssh then auth , give the location of ppk file
Now we can login without password!!!!!!!!!!!!!!
Few Troubleshooting
Server refused our key : Problem on Unix server , check the
authorized_keys file
Correct login
Then enter the password (Passphrase) for your private key
UNIX to UNIX (from server A to Server B)
On Server A
-
Logon to .ssh folder on Server A
-
Ran ssh-keygen -t rsa
-
Give blank for all the details ( screen shot )
Generating
public/private rsa key pair.
Enter
file in which to save the key (/home/beausr/.ssh/id_rsa):
Enter
passphrase (empty for no passphrase):
Enter
same passphrase again:
Your
identification has been saved in /home/beausr/.ssh/id_rsa.
The
key fingerprint is:
98:97:fc:12:d3:2c:dc:7c:25:25:79:87:89:2f:f2:0d
beausr@cic00152
-
that will generate two files
-rw-------
1 beausr beausr 883 Jan 02 08:46 id_rsa
-rw-r--r--
1 beausr beausr 225 Jan 02 08:46 id_rsa.pub
1.5
copy the id_rsa.pub to text file (it is
single line )
-
log on to server B
-
log on to .ssh folder
-
Create new file authorized_keys or edit the file
-
Then add server A’s private key their …. ( it is single line )
Step 5 to 8 can be done in single command
ssh-copy-id -i ~/.ssh/id_rsa.pub <IP of server B>
ssh-copy-id -i ~/.ssh/id_rsa.pub <IP of server B>
Example
: ssh-rsa
AAAAB3NzaC1yc2EAAAABJQAAAIEAklJzYkmTbFKi6xE9o1kYqEU3YS+iOmY6aNOPm2QmljbigiziqI6w+zrckBXiWvABtRdp712mrkTUPA7Idmss+0lWGRtHdgxxfDQsvJj5bpm56K/4Cw83nSvj3TdtvwUiri7X4sje12Qlr71iECqDZFwKayGTcK0M0bLuZY4C+a8=
rsa-key-20080102 - userid@serverA
1.9
Save authorized_keys and log
out
1.10
Now you can login from Server A to B without password (Only A to B
will work)
Few Troubleshooting
authorized_keys
is important one and edit it carefully .. There may be other users
using this
authorized_keys
: remove unnecessary spaces on the file
~
, your ~/.ssh
directory should be on permission ( chmod 700 )drwx------
2.Your ~/.ssh/authorized_keys should be ( chmod 600 )
3.SE linux can cause problem in some linux version , so you might need to disable it
On linux systems. ssh-copy-id can be used to copy
ReplyDeletethe .pub fie directly to remote systems.
ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/