ssh-keygen
And then follow steps on the screen.
ssh-add -l
eval $(ssh-agent)
(you will get output as - Agent pid XXXX)
ssh-add ~/.ssh/<private_key_file>
(Note: In Mac ssh-add is not persistant i.e. the keys will be lost if you restart or ssh-agent is terminated/restarted)
- By adding ssh key passphrase to your mac key chain
ssh-add -K ~/.ssh/<private_key_file>
- Create config file at ~/.shh by navigating to .ssh/ folder and using
nano config
- Type this code in config file and save it. Change id_rsa to the name of your key if using custom key
Host *
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
ssh-add -A
- .ssh directory - chmod 700 - (drwx------)
- public key (.pub file) - chmod 644 - (-rw-r--r--)
- private key (id_rsa) - chmod 600 - (-rw-------)
- home directory - chmod 755 - (drwxr-xr-x) - (should not be writeable by the group or others)