Jump to content


- - - - -

How to: Set up SSH Keys to log in on CentOS 6.5 from Windows

CentOS 6.5 Windows

  • Please log in to reply
No replies to this topic

#1 Wilson18



  • root
  • 112 posts
  • LocationUniversity of Birmingham

Posted 15 July 2014 - 01:37 PM

In this guide, I will be showing you how you can set up SSH Keys to in to CentOS 6.5. To do this, you will need to install Putty on your Windows machine you would like to log in from. You can download it here. Once you have done this, we will need to log in to our server by ssh.


Once logged in, we need to create our keys for the root user. 


Once you do this, you will be asked to choose a filename

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):

You should leave this blank and just press the enter key.

You will now be asked to enter a password. You can use a password if you like or leave this blank to log in to the server without a password.

Once you have done this, it should look like this:


Next, we need to change to the location where we store the keys we have just generated and change the permissions on them. 

cd ~/.ssh; ls; chmod 700 ~/.ssh; chmod 600 ~/.ssh/*

You should see the following been outputted. 

id_rsa  id_rsa.pub

The id_rsa  file is our private key (which we will be using) and the id_rsa.pub is our public key. 


What we need to do now is to authorise the key so that we are allowed to use it. 

cat id_rsa.pub >> authorized_keys

One last thing we need to do is to allow us to use the ssh keys in the configuration file. To do this, we need to install nano and the open it. 

yum install -y nano; nano /etc/ssh/sshd_config

The line we need to look out for is 

#AuthorizedKeysFile     .ssh/authorized_keys

You will need to remove the # symbol. You can then save and exit the file. 


Finally, we need to open up our private key and make a copy of it.

nano id_rsa

When his is open, it should look something like this


To copy this, you will need to highlight everything and then right click. This should also paste it. Once you have this copied, you should then exit the file WITHOUT saving it. 


We can finally restart our ssh server

service sshd restart

Now that we have done this, we are pretty much done CentOS now and we can swap back to windows. In Windows, you will need to open Notepad.exe and paste the key in to here and save it. It doesnt really matter what you save this as at the moment. 


Next, you need to open PuTTYgen. You will need to go to Conversions and click Import Key. 


You then select the key we created in notepad. If you chose a password earlier, you will need to enter this where it says key passphrase and then confirm it below. 


Click the save private key button. You can save the file as whatever you would like. 


Now we have done this, we will need to go into PuTTY. In PuTTY, you will need to enter your username@IP address and port in the port box. You can then go into the Connection settings and in to the SSH section and click Auth.  In auth, you can select your private key using the Browse button. 



Once you have done all of this, we can go back to session and save the session so we can connect at a later date without all of this. Enter the session name and save it. If you then click open, it should connect you without having to enter your username or password. If you had a passphrase, you will need to enter that instead.


  • Rolandcalm and KJwbUEfpgx like this

List what you read?

Check me out on: YouTube, Twitter, Facebook, Google+

Also tagged with one or more of these keywords: CentOS 6.5, Windows