I’ve tried many methods now of using SSH keys to login without a password. Needless to say, I had to mix a couple methods to make this work. This isn’t that hard.
Step 1) You’re on a linux machine (or putty’d into a linux box) trying to SSH into a remote host without having to use a password. In my case i need to run automated commands to upload files to a remote host. You need to create a SSH key for both machine. Do this by running the following command:
1 |
ssh-keygen -t rsa |
The default file should already be set, press enter.
The passphrase will remain empty (since you don’t want to type it every time you log in) Press Enter again.
Then press Enter for a third time to confirm the empty passphrase.
It should look something like the picture above.
Step 2) Upload the SSH Public Key to the remote server. Use the following command:
1 |
scp ~/.ssh/id_rsa.pub username@whateveryourdomain.com:.ssh/authorized_keys |
This will upload the file to your remote and will place the pub key file in .ssh/authorized_keys.
Now type “logout” to get out of your remote host’s SSH. Then log back in via:
1 |
SSH user@remotehost.com |
It shouldn’t ask for a password anymore. If any of this information doesn’t apply to you, or you have any questions please feel free to ask. Thanks for reading.
Thanks to the 2 sources that I used to come up with my own, thank you:
http://support.suso.com/supki/SSH_Tutorial_for_Linux
http://linuxproblem.org/art_9.html
~Steven Kohlmeyer