Monday, August 1, 2011

create ssh-keypair using putty-gen in windows

If you don't have puttygen, Download putty-gen utility from this link

You can also view the list of puttygen for various OS distros here

1. Download puttygen
2. Run the downloaded software.
3. You will be presented with the following API:

4. Click on "Generate" button. You will need to keep the mouse moving for generating random key. You will see the following image:
5. Save the private key. (You do not need to enter a passphrase if you dont want to enter the passphrase each time you login to the server using this key). Note the location in which you save the key. Give a suitable name. The extension will be ppk.

6. Save the public key. No extension needed. The contents inside this file will be the same which is highlighted under "Public key for pasting into OpenSSH authorized_keys file.

7. Now copy the contents of this public key into the proper location in the server into which you are logging into. The location should be as follows:

/root/.ssh/authorized_keys (if you need to login as root into the server)
or
/home/user/.ssh/authorized_keys (if you need to login as "user". /home/user is the home directory of the user and it can vary. if there is no .ssh directory inside the home dir of the user, then just create one and create the file authorized_keys inside it).

And you are done.

Now you can connect to the server using putty and the private key in your local machine using the following steps:

1. Run putty (not putty-gen). You can get putty.exe from the link here
2. As shown in the pic, expand "SSH" and select "Auth" in the left pane. Click "Browse" button and select the previously saved private key.

3. Now select "session" from the left pane and fill in the server IP address and ssh port and click on "Open" button.
PS: ensure that there are no default login names by clicking on "Data" option under the section "Connection" in the left pane.

You are done. Enjoy!

0 comments:

Post a Comment