Tuesday, April 12, 2011

Steps to do SSH Login from Remote Server without the password

Steps to do SSH Login from Remote Server without the password

Open 2 terminal screens - 1 for local and one for remote

1. ~/.ssh$ ssh-keygen -t rsa
    Press enter for the rest of the steps below
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/localadmin/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:

    You will get 2 files generated .pub is the public key and other one is the private key.
    :~/.ssh$ ls
    id_rsa  id_rsa.pub

2 :~/.ssh$ vi id_rsa.pub
 Now right click and copy the key

3. Go to remote server terminal screen
  Create a user using useradd -m "name of the user same as the user on your localhost"

 a. Now go to /home/youruser and create a directory .ssh
    remotehost:/home/youruser/.ssh# ls
    remotehost:/home/youruser/.ssh# nano authorized_keys

 Now paste the key which you copied in previous step
 b.
    remotehost:/home/youruser/.ssh# chmod 600 authorized_keys
    remotehost:/home/youruser/.ssh# cd ..
    remotehost:/home/youruser/# chmod 755 .ssh
    remotehost:/home/youruser# cd ..
    remotehost:/home# chown -R youruser youruser
    remotehost:/home# chgrp -R youruser youruser


4. Now come back to your localhost screen

    localhost:~/.ssh$ ssh usercreatedonremoteserver(Step 3 a)@remoteserveripaddress

     You should be able to login from the localhost

     Tip : change of owner and change of group is required. Step 3 b.

No comments:

Post a Comment