facebook twitter youtube
in LINUX - 20 Aug, 2011, This Tutorial Has Been Viewed 9,634 Times.
by admin - no comments
SSH without password from one server to another in unix aix or linux
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

There are lot of requirements in the production environment where there is a need to have SSH without password prompt from one server to another under some id’s. But how to do that. Here is the solution and tips on how to approach this method without any bugs.

First of all lets take 2 servers
SERVER A and SERVER B
Here my requirement is to make some script which is in SERVER A copy some files from SERVER B and do some data updating activity in SERVER A.

STEP 1
Switch to the ID where you need the process to be running. [MAKE SURE THAT YOU HAVE HOME DIRECTORY SET FOR THE RESPECTIVE ID ON BOTH THE SERVERS]
Generate SSH keys in SERVER A.

ssh-keygen -t rsa

This will create PUBLIC KEY with an extension .PUB and another key which is the PRIVATE KEY inside the
/home/YOUR_ID/.ssh directory.

STEP 2
Now Login to SERVER B and CHANGE DIRECTORY [cd command] to the home directory of the same id. Then copy the content of the PUBLIC KEY that was created in to a file named authorized_keys with command

cat <filename>.PUB >> authorized_keys

YOU ARE SET NOW :)

Logout of SERVER B and LOGIN WITH THE SAME ID ON SERVER A
Issue command

ssh SERVER B

This will take you to SERVER B without any password prompt.

NOTE

Make sure the home directory permission
/home/YOUR_ID This should be 755
The other files like PRIVATE AND PUBLIC KEYS and also the AUTHORIZED_KEYS should have only 600 permission. THIS IS A MUST OTHERWISE IT WONT WORK.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Incoming search terms:




coded by nessus

Leave a Reply

Close
Please support the site
By clicking any of these buttons you help our site to get better