SSH is secured alternative to telnet. Unlike telnet, ssh packets are transmitted encrypted. On the same line SCP, copies files from one destination to another, securely. Source(Destination) can be over network also.
Auto-login for the telnet can be done using ‘expect’, which require expect package also a little bit knowledge of shell scripting. On the other hand, SSH provides a more cleaner approach for auto-login. Keys are exchanged(stored) between the hosts enabling auto-login.
To elaborate the steps, consider user(user1) on machine1 wants to do auto login as a user(user2) on machine2. Perform following step on the respective machine. On machine1, give the following commands
- user1@machine1>> ssh-keygen -t rsa
The above command would generate id_rsa and id_rsa.pub in $HOME/.ssh directory(default). Transfer the generated id_rsa.pub file to machine2 , using ftp or scp.
- user2@machine2>> cat id_rsa.pub >> .ssh/authorized_keys
- user2@machine2>> chmod 600 .ssh/authorized_keys
Thats all, you are done.
Note : Please make sure that the home directory of the user2 is not writable by any one else (permission of 755)
now when you do a ssh to user2@machine2 from user1@machine1, you would not be asked any password. Even “SCP” would work with out any password. As an shortcut you can define alias for the ssh for machine2 in .profile, like
alias machine2=”user2@<machine2 ip >”
and when you give machine2 on the shell, you would directly ssh to the machine2. As an description of what is going on under the hood, private key of user1@machine1 is stored as authorized in user2@machine2. So for authorization; keys are used instead of password.