Easy SSH On macOS

Using public key authentication for ssh is safer than password. But you should really use a passphrase protected private key. Now you are safe but you still need to type in your passphrase. This isn’t bad, however if you are ssh-ing one hundred times a day becomes cumbersome. If you are using a Mac this can be easily fixed with adding your private key to keychain. After this whenever your keychain is unlocked ssh client won’t ask again for your passphrase.

This is how you can set this up:

ssh-add -K ~/.ssh/id_rsa 

now add the following lines to: ~/.ssh/config

Host *
  UseKeychain yes
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_rsa

Where id_rsa is your private key, good luck! Now you must NOT forget to lock your screen when you walk away from your computer (Ctrl+Cmd+Q)!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.