Setup SSH access without password

Say you have two machines one client and the other server. You want to ssh <server_user>@<server> from <client_user>@<client> without password. Follow the following steps:-

  • Login as <client_user> on <client> machine.
  • run command :
    ssh-keygen -t rsa
    

    hit enter for any prompts. This shall create two files id_rsa (private key) and id_rsa.pub (public key) under ~/.ssh directory on <client> machine.

  • The following command shall append the contents of ~/.ssh/id_rsa.pub to /home/<server_user>/.ssh/authorized_keys on <server> machine.
    ssh-copy-id -i ~/.ssh/id_rsa <server_user>@<server>
    

    alternatively you can

    scp ~/.ssh/id_rsa.pub <server_user>@<server>:/home/<server_user>/
    cat ~/id_rsa.pub >> /home/<server_user>/.ssh/authorized_keys
    rm -f cat ~/id_rsa.pub
    logout
    
  • ssh <server_user>@<server>
    cd ~/.ssh
    chmod 600 authorized_keys
    

logout server and you are done! try doing ssh or scp, it wont prompt for an password.

Leave a Comment

Your email address will not be published.