SSH keypair authenticated login automation

April 22, 2009

I have had to do this a few times, and it’s really handy. Making a SSH keypair that will allow me to login on a remote machine without entering a password.

Here are the commands:

On my machine (primary host) I want given permission to access remote machines

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ryan/.ssh/id_rsa): <ENTER>
Enter passphrase (empty for no passphrase):  <ENTER>
Enter same passphrase again:  <ENTER>
Your identification has been saved in /home/ryan/.ssh/id_rsa.
Your public key has been saved in /home/ryan/.ssh/id_rsa.pub.
The key fingerprint is:
fa:e7:7c:e1:cb:7b:66:8b:67:07:05:99:7f:05:b9:4a ryan@localhost

I then copy id_rsa.pub out to the remote machines user directory, so my localhost user can access the remote host user account without password, a network of trusted hosts .

$ mkdir remote_server/.ssh
$ chmod 700 remote_server/.ssh
$ cat .ssh/id_rsa.pub >> remote_server/.ssh/authorized_keys
$ chmod 600 remote_server/.ssh/authorized_keys
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: