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:
- ssh-keygen -t rsa && ssh-keygen -t dsa #create the keys
- cat ~/.ssh/*.pub >> `hostname -s`.keys #put them into one file for easy transfer
- scp `hostname -s`.keys user@remotepc:~/.ssh/ #transfer them to user@remotepc's ssh configuration directory
- ssh user@remotepc #ssh to remote pc as the user who will login without any password
- cat ~/.ssh/*.keys >> ~/.ssh/authorized_keys #add the keys to the users authorised keys file
- chmod go-w ~/ #set correct permissions on the user's home directory - no need for the world to enter his directory at all
- chmod 644 ~/.ssh/authorized_keys #set proper permissions on the authorised keys file
- chmod 700 ~/.ssh #set proper permissions on the .ssh directory
exit and test by
ssh user@remotepc
Comments
actually its called "ssh
actually its called "ssh private keys" and here are some links:
first link
second link
third link
well now, instead of that
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
a faster method of generating keys
____________________________________
I am the Site Owner and I post my notes here.