Passwordless SSH and SCP

On Mac

Remove or backup existing keys.

$ rm ~/.ssh/id_rsa

$ rm ~/.ssh/

$ chmod 700 ~/.ssh

Generate a ssh key pair. For more instruction following this link

$ ssh-keygen -t rsa -b 4096 -C ""

Copy the to the server using scp command

$ scp ~/.ssh/ <username>@<servername>:~/Downloads/

On Server

Create a directory

$ mkdir ~/.ssh

Copy pub key to authorized key list

$ cat ~/Downloads/ >> ~/.ssh/authorized_keys

Change the permission to 600

$ chmod 600 ~/.ssh/authorized_keys

Now you should be able to ssh and scp without entering password. You can reuse the public key to more than one server to setup passwordless SSH. Sharing public key on multiple server does not increase security risk. Make sure that you DO NOT share the private key (id_rsa) to keep it safe.