Creating a strong SSH key pair for file transfer without a password
Passwords really get in the way of scripts that have to automatically transfer files. They can also be annoying if you’re logging into the same machine all the time. If you create a key pair between two machines however, the account you created it for won’t have to provide a password when accessing the other machine. Note these are 1 way, meaning if you put computer A’s ssh key on computer B, A can log into B without a password, but B still needs a password to log into A.
Steps to set it up
- Create the Key Pair. Just hit enter for all the options and it will put the files in the .ssh/ folder
ssh-keygen -t rsa -b 4096
- SSH the .pub file to machine B, the machine you want to be able to log into without a password.
scp .ssh/id_rsa.pub email@example.com.B:
- Append the contents of the .pub into the .ssh/authorized_keys file of machine B
cat id_rsa.pub >> .ssh/authorized_keys