You are here

ssh passwordless login

every once in a while i have to set up a couple of servers (or more) to communicate with each other via ssh. but the problem is that the scripts need to be run on the remote server. the script would of course stop to ask me for the password. the solution is something some people call user equivalence or some just call it passwordless ssh login. in any case, here is the process:

  1. ssh-keygen -t rsa && ssh-keygen -t dsa #create the keys
  2. cat ~/.ssh/*.pub >> `hostname -s`.keys #put them into one file for easy transfer
  3. scp `hostname -s`.keys user@remotepc:~/.ssh/ #transfer them to user@remotepc's ssh configuration directory
  4. ssh user@remotepc #ssh to remote pc as the user who will login without any password
  5. cat ~/.ssh/*.keys >> ~/.ssh/authorized_keys #add the keys to the users authorised keys file
  6. chmod go-w ~/ #set correct permissions on the user's home directory - no need for the world to enter his directory at all
  7. chmod 644 ~/.ssh/authorized_keys #set proper permissions on the authorised keys file
  8. chmod 700 ~/.ssh #set proper permissions on the .ssh directory

exit and test by

ssh user@remotepc

Comments

actually its called "ssh private keys" and here are some links:

first link

second link

third link

well now, instead of that copy from machine to machine and adding stuff to authorized_keys just do this

ssh-copy-id user@remote_pc

____________________________________

I am the Site Owner and I post my notes here.

a faster method of generating keys

cd ~/.ssh
ssh-keygen -t dsa -P "" -f /home/$USER/.ssh/id_dsa
ssh-keygen -t rsa -P "" -f /home/$USER/.ssh/id_rsa
cat *pub > "$USER"_`hostname -s`.key

____________________________________

I am the Site Owner and I post my notes here.