Archive for October, 2013

SSH authentication using key pairs

October 3rd, 2013 No comments

This is more of an aide-mémoire for me than a public guide. If it is helpful for other people then I am happy to make it available. If anyone has any comments or suggestion please contact me.

. . .

This example is for Debian however it should work on most flavours.

  • Log on to the client machine as the user who will be accessing the server
  • Generate a key pair using the following command:
$ ssh-keygen
  • Use the default directory to save the key
  • [optional] To use SSH authentication without entering a password simply hit enter (otherwise enter a pass phrase)
  • The key will be created and stored in the ~/.ssh directory
  • We now need to install the generated key on the server using the following command:
$ ssh-copy-id -i .ssh/ username@serverip
  • When asked enter the password to log on to server. The key will then be added to the server and confirmation message will be displayed.
  • Finally a bit of housekeeping / security. Protect the SSH keys:
$ chmod go-w ~/
$ chmod 700 ~/.ssh
$ chmod go-rwx ~/.ssh/*

That should be it…

Categories: Debian, Linux, SSH Tags: , ,