Sometimes you work with your remote host so much, that having to enter a password every time becomes a real pain. If that is the case, you should follow with this instructions to set up automatic handshake with your remote host.
First off, you have to have OpenSSH on both the host and your local machine. SSH into your remote host to create the “.ssh” directory in your home folder.
Now we are going to use the SSH Key Generator to create the authorized key.
ssh-keygen -t dsa
You will be prompted to enter a passphrase for this identity key. Choose something hard to break.
Now all you have to do is copy the identity key to the remote host.
scp ~/.ssh/id_dsa.pub email@example.com:.ssh/authorized_keys2
Of course, you will replace “firstname.lastname@example.org” with your actual remote host’s access information. Now, you will run a simple script that will tell the remote host which identity it should use, and also starts a new shell that will enable you to SSH to the remote host without entering any passwords.
ssh-agent sh -c 'ssh-add < /dev/null && bash'
Now try typing “ssh email@example.com” and you will see that you are all set.
2 thoughts on “Setting up SSH keys”
Instead of the scp line, consider using ssh-copy-id. Also, I think most people use:
eval `ssh-agent` in their .Xsession or a similarly placed script for their X environment so as to share a common ssh-agent.
Hmmm, cool. Well, at the time of writing this I wasn’t aware of the `ssh-copy-id`. But I ended up knowing about it eventually.
Thanks for the comment, though. Much appreciated.