SSH to Remote Site without password

posted in: Linux 0

When running ssh or scp from a script, there is a need to establish a connection to the remote site without being prompted for a password. This quick reference should get the job done.

Create Public Key Authentication

# ssh-keygen -t rsa

Press enter twice to create a key without a pass phrase. Then copy .ssh/ to remote computer, placing it in the .ssh folder.

 # scp .ssh/ userid@xxxxxxx:.ssh/

Logon to remote computer and build authorized key ring

To add the new key to the authorized keys, append the new key to authorized_keys file. Note the access level of the file should be 600. SSH is very picky about this and may not accept a less restrictive access setting.

# cd .ssh
# cat >> authorized_keys
# chmod 600 authorized_keys

Finally, logout of the remote computer and logoff and log back on local/client computer – do not skip this step if you generated the key in this session.

Test the change by ssh to site. If no password is requested, it worked.


If the ssh test prompts for the password, then rerun ssh with the option -vvv to get the detailed debugging information.

1) Make sure you logged out of the local account and back in. This reloads the credentials.

2) Make sure the file was appended to the authorized_keys

3) Verify the permissions on the file (600 works for me on Fedora 14) and 700 on the .ssh folder.


Comments are closed.