How to Add Your Public SSH Key to Remote Host With a Single Command

2020-04-21 OS X

Adding your public SSH key to remote host will allow you to SSH without typing password over and over again.

Open your terminal on your local machine and type:

cat ~/.ssh/id_rsa.pub | ssh [email protected] 'cat >> .ssh/authorized_keys'

This is self explanatory. Replace host-user and host-ip-address with your real values. You should be prompted for your password for the very last time.

Once that’s done, exit to disconnect and ssh into this host again. From now on you should be ssh’ed without a prompt.