How to Set Up a Password-less SSH Login

Setting up passwordless SSH logins is a great way to speed up connections to regularly accessed remote Linux and Macs boxes. This is how to set everything up, it only takes a minute or so.

First, on the local machine you will want to generate a secure SSH key:

ssh-keygen

Walk through the key generator and set a password, the key file by default goes into ~/.ssh/id_rsa

Next, you need to copy the generated key to the remote server you want to setup passwordless login with, this is easily done with the following command string but you can use scp if you’d prefer:

cat ~/.ssh/id_rsa.pub | ssh user@remotehost 'cat >> ~/.ssh/authorized_keys'

This command takes the generated SSH key from the local machine, connects to the remote host via SSH, and then uses cat to append the key file to the remote users authorized key list. Because this connects with SSH to the remote machine you will need to enter the password to use this command.

Finally, confirm that you can now login to the remote SSH server without a password:

ssh user@remotehost.com

By Posted in Tip & Tricks on Aug 22, 2012

Print This Listing
Author: CloudFarm

As Information Technology Officer, Nicola Tonon leads EIUC’s central IT system. As ITO, he is in charge of making sure that all IT strategic initiatives are in line with the EIUC’s mission, culture, and long-term goals. The ITO is responsible for IT-related issues ranging from policy and resource allocation to protocol and organization. Nicola has a deep understanding of the importance technology plays in research and related activities and is committed to finding new ways to support staff and students and endeavours through the use of technology. He works closely with students and staff to deliver programmes and services that enhance teaching, research, and student activities.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>