Showing posts with label passwordless. Show all posts
Showing posts with label passwordless. Show all posts

Thursday, February 14, 2008

Micro-Recipe: Generate keys for passwordless SSH & SCP

Micro-recipe to avoid entering your password each time you do an ssh or an scp from a local machine to a remote one.

Local machine (enter passphrase each time) ->

  • ssh-keygen -t rsa1
  • ssh-keygen -t dsa
  • ssh-keygen -t rsa (if you do only one, do this one)
Remote machine ->
  • Append the content of each of the local ~/.ssh/identity.pub, ~/.ssh/id_dsa.pub, ~/.ssh/id_rsa.pub files to the remote ~/.ssh/authorized_keys one each time on a separate line.
Local machine ->
  • Execute this script every time you restart your linux box to start the ssh agent.
ssh_info_file=~/.ssh-agent-info-`hostname`
ssh-agent >$ssh_info_file
chmod 600 $ssh_info_file
. $ssh_info_file
for i in identity id_dsa id_rsa
do
ssh-add ~/.ssh/$i
done


Attach each shell to the ssh agent.
  • . ~/.ssh-agent-info-`hostname`
Complete recipe: http://www.cvrti.utah.edu/~dustman/no-more-pw-ssh/