Creating SSH keys

SSH keys provide secure authentication and access to remote machines and as a result can allow secure logins without passwords. As such, this is a secure method to speed up logging in to frequently-accessed remote machines.

Requirements

Procedure

Instructions for a Mac/Linux local machine

  • launch Terminal or Command Line
  • generate the keys:
    • ssh-keygen -t rsa 
    • hit enter to save the key in the default ~/.ssh/id_rsa
    • hit enter for no passphrase
  • secure the keys:
    • chmod -R go= ~/.ssh
  • copy the public key to the remote account home folder:
    • scp ~/.ssh/id_rsa.pub username@remoteserver:
  • switch to Terminal or Command Line on the remote machine

  • create the directory to store the public key:
    • mkdir ~/.ssh
  • append the public key to the appropriate file:
    • cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
  • remove the public key from home folder:
    • rm ~/id_rsa.pub
  • secure the directory:
    • chmod -R go= ~/.ssh
  • test secure authentication to the remote machine; it should no longer require a password
    • ssh username@remoteserver