Generate a key if needed:
ssh-keygen -t rsa
It should now be located in: ~/.ssh/
as id_rsa
and id_rsa.pub
.
Install ssh-copy-id if needed:
brew install ssh-copy-id
Add SSH key to server:
ssh-copy-id [email protected]
Before the next step test loggin in with your key! You will be locked out of your server!
Remove root and password login (on the server):
sudo nano /etc/sshd_config
...
PermitRootLogin no
...
PasswordAuthentication no