Managing SSH Keys

SSH (Secure Shell) can be set up with public/private key pairs so that you don't have to type the password each time. Because SSH is the transport for other services such as SCP (secure copy), SFTP (secure file transfer), and other services (CVS, etc), this can be very convenient and save you a lot of typing.

Frequently used hosts can be saved in ~/.ssh/config. There's an Alfred workflow that reads the SSH config — just type ssh.

Reference: cyon.ch — SSH Key erstellen

Connect a new server via SSH keys

  1. Generate a new keypair with a passphrase, save the output to Password Manager
    ssh-keygen -t rsa -b 4096
  2. Upload public key to the hosting provider (e.g. cyon). ssh-copy-id should work but didn't in my case — upload manually instead.
  3. Add the new host to ~/.ssh/config with the key
  4. Connect for the first time and enter the password once (not needed for following connections)

SSH agents

To avoid typing the key passphrase on every connection, use ssh-agent to cache keys with their passphrases.

eval 'ssh-agent'
ssh-add ~/.ssh/idrsakey

Reference: Using ssh-agent