Scenario
You have two Linux servers and you want to ssh or you want to do scp(to copy some files to the other server) without any password. This can be useful if you want to create a script to copy files from one server to another as backup
First Linux server :192.168.1.10
Second Linux Server :192.168.1.11
install ssh on both of them
#apt-get install ssh
In the First Server
1. Login as root
2. ls -al /root/
3. try to find a folder ".ssh"
4. if their is any files or folder other than 'known_hosts' delete it by using following command
5. Now generate ssh keys, follow steps
6. ssh-keygen -t rsa
7.Don't give any passphrase -This is important
8. Press enter again & again untill you get command prompt again.
9. Now you will find few files one of them will be "id_rsa.pub" in the .ssh folder
10. copy this file to the second linux machine, follow steps
11. scp /root/.ssh/id_rsa.pub root@192.168.1.11:/root/
12. you will be asked for root password, type your password, press enter
13. now log on to 192.168.1.11 as root
14. type the sequence of following commands
15 .cd ~/.ssh
(. if it is their then follow the command sequence below, or create .ssh folder by typing following command mkdir .ssh)
16. now add the key to your authorised keys, follow the steps
17. cat /root/id_rsa.pub >> /root/.ssh/authorized_keys --->> press enter
18. go back to your 192.168.1.10, type the following command
19. ssh root@192.168.1.11
20. you should be loged in to it without any password
21. repeate step 11 to 19 on all machines you want to logon without password
No comments:
Post a Comment