Password less authentication for SFTP/SSH between two host
Hello Viewer,Below are the steps to establish password less authentication between two host.
Example :
you are on "machine1.info.company1.com" and you want password less authentication on "machine2.info1.company2.com" for user "shyam"
Follow the below steps:
1) Log in to "machine1.info.company1.com" with user "user1".
2) Go to below directory:
cd /home/user1/.ssh/
3) Generate public-private key pair using below command.
ssh-keygen -t rsa
Enter file in which to save the key (/home/web/.ssh/id_rsa):Press Enter
Enter passphrase (empty for no passphrase): Press Enter
Enter same passphrase again: Press Enter
Your identification has been saved in /home/web/.ssh/id_rsa.
Your public key has been saved in /home/web/.ssh/id_rsa.pub.
Verify the date of the above files.
4) SSH to other machine and perform below steps.
ssh shyam@machine2.info1.company2.com , enter the password
cd /home/shyam
Change .ssh directory to 700 permission
cd .ssh
Take the backup of authorized key folder
Change authorized_keys to 600 permissions
ctrl+C
5) Execute the below command:
cat /home/user1/.ssh/id_rsa.pub | ssh shyam@machine2.info1.company2.com 'cat >> .ssh/authorized_keys'
6) Close the current session and again log in to "machine1.info.company1.com" with user "user1"
7) Try ssh shyam@machine2.info1.company2.com
This time it should not ask for the password.
Thanks a lot for your patience!!!
Regards
-Ashish
No comments:
Post a Comment