Tutorial – Passwordless SSH Using Private Keys with CentOS 6

This document we’ll go through the process of configuring SSH client to login without a password using a private key. This can be a convenient, fast and potentially more secure way to access a remote system… Best thing, it’s actually very simple to achieve!

Step 1: Generate Your Key

Start by being logged into your local system and generate your private key using the command “/usr/bin/ssh-keygen”:

We now have a generated private and public key set, the key’s are typically created as /home/user/.ssh/id_rsa & /home/user/.ssh/id_rsa.pub.

[box type="warning"] Beware that your private key is an extremely valuable file. It’s like storing your password in a file. If obtained, could be used by another person to access your systems. Back it up and keep it safe!![/box]

Step 2: Share Your Key

To use your private key, you must share your public key with a remote server. Simply put, the remote server keeps a copy of your public key, which it uses to match against your private when you attempt to login.

There is a utility which automatically installs our public key onto a remote host; ssh-copy-id. Obviously it won’t work unless you already know the password of the account on the remote host.

…and that’s it. The ssh-copy-id program automatically copied our shared key into /home/user/.ssh/authroized_keys file on server2.

Step 3: Login with no Password

Assuming you’ve followed the above steps, all you simply have to do now is login to the system as per normal.

..boom and you’re in, no password entry required!
[box type="info"] Just note that this document assumes CentOS 6 for all example code and references. Syntax, file locations and codes may vary based on your distribution.[/box]

[author] [author_image timthumb='on']http://mcdee.com.au/wp-content/uploads/2012/11/photo.jpg[/author_image] [author_info]Andrew McDonald is an IT Systems Admin and all round technology junkie. Absolutely a jack-of-all-trades and not one to shy away from a challenge.


 [/author_info] [/author]

Leave a Reply

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


× 5 = forty five

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