raspberryPi 3

Multiple ssh-keys / identities

setup .ssh/config file with your various identities

Make sure that the identity is added/available to the ssh agent:

Make sure that your .ssh directory and your authorized_keys file inside of it are rwx only to you, not to group or others

  • Check to see if your SSH key is loaded:
    • $ ssh-add -l
  • If you don’t see your key listed, add it by entering ssh-add followed by the path to the private key file:
    • $ ssh-add ~/.ssh/<private_key_file>
  • To generate a new key/identity:
    • $ ssh-keygen -f ~/.ssh/<keyname, ie bitbucket>
    • Make sure to add it by entering ssh-add followed by the path to the private key file:
      • $ ssh-add ~/.ssh/<private_key_file, ie bitbucket>
    • You can also simply use it by adding a host entry to the .ssh/config file and then typing ssh <hostname>
  • To setup ssh keys on the remote system
$ mkdir .ssh && chmod 700 .ssh
$ touch .ssh/authorized_keys 
$ chmod 600 .ssh/authorized_keys
  • To copy your key to another system:
    • $ ssh-copy-id user@<ip address>