Passwordless SSH setup for MacOS Hosts

A tiny handbook to setup passwordless ssh in MacOS
macOS
Author

Zeel B Patel

Published

May 14, 2023

Terminology

HOST: The computer physically present with you.
REMOTE: The remote computer that you’d like to access via ssh.
REMOTE-IP: Ip address of the REMOTE.
PORT: The port on which the ssh server is running on REMOTE.

ssh-keygen # this will generate a public and private key pair. Rename it if you want.
ssh-copy-id -i ~/.ssh/id_rsa.pub -p PORT USERANAME@REMOTE-IP # this will copy the public key to REMOTE
ssh-add ~/.ssh/id_rsa # this command tells the HOST to use the private key for ssh connections

That’s it! You should now be able to ssh into the REMOTE without a password. After rebooting the HOST, if VSCode or CLI asks for a password, run ssh-add ~/.ssh/id_rsa again.