Using RSA key of a remote machine you can authenticate for SSH for that machine without entering a password. Generating RSA key is very easy and simple. Follow the procedure below to generate keys for two machine. Machies: 1) mirage (192.168.36.205) and students (192.168.36.200).
Step 1
use this command on mirage server
1 2 3 4 5 6 7 8 9 | [kulbir@mirage ~] ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 32:30:af:c6:0b:e2:c0:60:92:fd:62:da:37:32:f2:ce root@LocalHost |
You should get the result as above and if it asks to overwrite something then overwrite it.
Step 2
1 2 | [kulbir@mirage ~] scp ~/.ssh/id_rsa.pub user@192.168.36.200:~/.ssh/authorized_keys2 user@192.168.36.200''s password: |
Now if the above operation was successful, then you can login from your mirage account to your students account without a password. Try it, and if it is successful then do the same for your students server. Now you don’t need type your password again and again to login from one server to the other.
If the above worked for you, then there is one more thing you can try out. Go to .ssh/ directory in your home directory and create a file named ‘config’. Now write in that file
1 2 3 4 | host students hostname 192.168.36.200 port 22 user kulbirsaini |
and save the file. You have to specify the port on which SSH is listening. Save this file and now you can login by just typing
[kulbir@mirage ~] ssh students [Enter] |
You can write whatever you want in place of ‘students’ in the file and then login typing ssh ‘word’ that you have written against the host in file.
well the prev comment was posted by me long back..that is becuase you kept some “all copyrights ..” stuff.I’ve n’t checked the config part of it.The config thing is pretty nice.How many entries can we have in the config file ? and how is its format in case of more than one account ?
@koorma well i tried it for three entries and it worked out. you may want to try it for more ….
here is the format ….
host mylabpc
hostname 172.16.26.30
port 22
user guest
host t
hostname 292.268.362.250
port 22
user kulbirsaini
host workspacepc
hostname 272.26.26.24
port 22
user guest