Friday, April 23, 2010

rlogin: How to login to a UNIX account without password?

       Every UNIX user logs into a user account by giving the username and password. There are situations when a user has to login to a particular account many times during the day. It would have been easier had the user not been asked to provide the password every time he tried to log-in.

     There are many ways in which a user can login to an account without password. In this article, we are going to see how to use the rlogin command to achieve this.

    The basic use of rlogin command is to do a remote login. Though the name tells 'remote login',the rlogin command can be used to login  to a user account of the same machine or a different machine.

Using rlogin to login to a user account in different box:

    Let us consider a scenario. A user 'gpr' in UNIX box 'SandalWood' tries to login to the user 'blogger' in UNIX box 'TeakWood'.

  1. In the home directory of the user 'blogger' in 'TeakWood', create a file .rhosts if not present and add the following contents to it.

#cat $HOME/.rhosts
SandalWood gpr

  2.  The user 'gpr' should now execute the rlogin command from 'SandalWood' box as shown below:

#rlogin TeakWood -l blogger

   When  issuing the above rlogin command, the user will now be directly taken into the user account 'gpr' without being prompted for password.

     Whenever the rlogin command is used, it first checks for .rhosts file in the destination user account's home directory. On finding the .rhosts file, it tries to find the entry for the remote user being logged. If a valid entry exists, the user gets considered as a trusted user and hence not prompted for password.

Using rlogin to login to a user account in the same box:
  If the rlogin command is used to login to a user account of the same machine, the hostname need not be specified in the .rhosts file. In place of hostname, the symbol '+' can also be used as shown in the below example: 
#echo $USER
#cat $HOME/.rhosts
+  blogger

     The above entry in the .rhosts file will allow the blogger user 'blogger' to login to the user account 'gpr' without password.

No comments:

Post a Comment