If you have 100 Linux/Unix servers to manage, it’s painful to remember all the password. You can setup SSH without password to your server, it saves time and also secure login to all your servers. When I mentioned “secure”, it’s secure at the server side, allow Public Key login only. But, you must also consider secure your client machine, once someone granted all to your client machine, they can access to all your server without password as well 🙂 You might want to consider the risk of SSH without Password on your client machine.
Before setup SSH without password, you have to configure a few things on client machine.
Generate Keys on Client Machine
- Follow the steps below to generate RSA/DSA Key
- On your client machine, type: ssh-keygen -t rsa
- When it asks for passphrase, leave it empty
- You key should be located at .ssh/id_rsa and .ssh/id_rsa.pub
- id_rsa is your private key, keep it for yourself only
- id_rsa.pub is your public key, which will use on the Server Side
Setup Public Key on Server Side
Follow the step below to setup public key on server side.
- Copy the public key on your client machine, which is id_rsa.pub
- Access to Server Side, create .ssh directory by: mkdir .ssh
- Create a new file named authorized_keys by: vi .ssh/authorized_keys
- Paste the id_rsa.pub value in authorized_keys and save it
- Change to mod of authorized_keys to 600 by: chmod 600 .ssh/authorized_keys
- Change the mod of .ssh folder to 700 by: chmod 700 .ssh
- Make sure .ssh folder and authorized_keys ownership is your userid
You are done, try to remote access to the server, it should not prompt your for password.