To access SSH without entering password every time.
You can generate a public/private key pair, and authorize the public key on remote server.
Essential if your need to run automated scripts.
Works on Linux / Mac / Windows (Under bash)
(For Windows + PuTTY, check the tutorial here)
- Prepare public/private on your LOCAL machine
Runssh-keygenunder bash (Press ENTER 3 times without entering passphrase)
Your you get your public key is under~/.ssh/id_rsa.pub, and private key under~/.ssh/id_rsa - SSH to REMOTE machine with password
On the REMOTE account you want to have access to,sudo -iif your want to authorize root
mkdir ~/.ssh/
vim ~/.ssh/authorized_key
Paste the content of~/.ssh/id_rsa.pubon your LOCAL machine. - Disconnect from your REMOTE machine, and try to
sshagain.
No password will be prompted if key is installed correctly.
Hints 1: ssh / rsync… etc command automatically pickup private key in ~/.ssh/id_rsa
If you have multiple key pair, you can specify it with ssh 1.2.3.4 -i ~/.ssh/id_rsa_other,
or set it permanently by ~/.ssh/config, follow tutorial here
Hints 2: If you connect to remote user name different than your local user name,
Instead of ssh [email protected] every time, you can edit ~/.ssh/config and add config just like previous hint.
So you can simplify your command from ssh [email protected] -i ~/.ssh/id_rsa_other to ssh 1.2.3.4
Host 1.2.3.4 User root IdentityFile ~/.ssh/id_rsa_other
One Reply to “[Windows/Mac/Linux] Password-less SSH Access and Hints”