SSH Login Without Password
You can log in into a ssh session without having to type a password by using RSA Key authentication.
Let's say HOME is where we'll be connecting from and OFFICE is where we will connect to. The remote OFFICE user is worker
Generate Authentication Keys
ssh-keygen -t rsa
The output will be something like:
Generating public/private rsa key pair. Enter file in which to save the key (/Users/rest/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/rest/.ssh/id_rsa. Your public key has been saved in /Users/rest/.ssh/id_rsa.pub. The key fingerprint is: SHA256:dSklce3rzGeYdt1c1dlCr5/lQ8omilOdjm1pfmMagOM firstname.lastname@example.org The key's randomart image is: +---[RSA 2048]----+ | o.o. | | + .o | | o oo .+| | .. o o.=| | oS.. . +.| | . ...o o.o| | E. +.o+o**| | ... B.BBoX| | ...=o*..+.| +----[SHA256]-----+
Create Remote .ssh Directory
Now use ssh to create a directory ~/.ssh as user worker on OFFICE. (The directory may already exist, which is fine):
ssh worker@OFFICE mkdir -p .ssh
Append Public Key to Remote Host
Finally, append HOME's newly created public key into OFFICE's ~/.ssh/authorized_keys file:
cat ~/.ssh/id_rsa.pub | ssh worker@OFFICE 'cat >> .ssh/authorized_keys'
Login Without Password
From now on you can log into OFFICE as worker without having to type a password: