SSH keys in 2 easy steps
February 13, 2010
These are simple instructions that will let you ssh from one Linux machine to another without needing to type your password.
Step 1) Generate your public signature
On your local machine (where you are ssh-ing from) type:ssh-keygen(Then hit ENTER to accept the default output file of ~/.ssh/id_rsa.pub and ENTER again twice if you're lazy and want to use a blank passphrase.) Note that you only have to generate a key once per client machine - the same public key will be used to access all servers.
Step 2) Copy your public signature to the server
Again, from your local machine, type:cat ~/.ssh/id_rsa.pub | ssh remote_user@remote.example.com "cat >> ~/.ssh/authorized_keys"(but replace remote_user@remote.example.com with your actual user and server.)
This fancy shell command appends the contents of your public signature to the end of the ~/.ssh/authorized_keys file on the server. (If you did a simple scp it would overwrite any previous authorized keys you've stored.)
You're done!
Next time you ssh into the serverssh remote_user@remote.example.comIt should do this without prompting for any passwords. blog comments powered by Disqus