Tuesday, 7 August 2007

SSH Keys Authentication

I have come accross it a thousand times, and I still forget some key details when I try to set it up again, so I will post it here for everyone. It is very convenient to use ssh with key authentication. It saves lots! of typing. The following example is for version 2 DSA keys.

Step 1: From the client system generate your dsa keys
  • ssh-keygen -t dsa (no passphrase)
Step 2: Let the server give you authorization for your key authentication
  • copy your local public key into the server's "authorized_keys" file, in you homedir's .ssh directory
Step 3: Make sure your client is using the newly generated key (if you accepted the default key filename (id_dsa) this shouldn't be necessary)
  • ssh -i my_private_key_file me@myhost, or...
  • add this to your ~/.ssh/config file:
  • "Host mysshservername" and "IdentityFile my_key_filename"
That's it!

No comments: