Sites

Wikipedia
SlashDot
Gentoo Linux
Loop-AES Encryption
Geoiptool

Tuesday, June 30, 2009

How To Configure SSH To Use KEY Authentication (example W/Putty Client)

I will explain how you can replace password-based SSH authentication with key-based authentication which is more secure because only the people that own the key can log in. In this example, we're using PuTTY as our SSH client on a Windows system.

Download And Extract Putty, You Need the Full Package, not just putty.exe.
Now Run puttygen.exe

press Generate button, move mouse. Once the keys are generated, type your key passphrase (choose a "hard to guess" one). Save Public key. Save Private key.


Configuring Linux Server

From The Root Shell(Example Using Username sshtest):


adduser sshtest --disabled-password

Now Do the Following:


su sshtest
cd /home/sshtest
mkdir .ssh
chmod 700 .ssh
cd .ssh

Now we need to open authorized_keys2:


nano authorized_keys2

Next cut & paste your public ssh key, on ONE LINE (THIS is very IMPORTANT!!!)

Notes:

Do not add the email@example.com at the end of the line.
Do not add the BEGIN PUBLIC KEY or END PUBLIC KEY.
Do not add the rsa-key-20090614 at the end.
Make sure, there is ssh-rsa at the beginning.

example:
ssh-rsa AAAAB3NzaC1yc2ELAABBJQAAAIBzPeFQv+295iKzuuPF0jE9429pSHVpDwBvAR9EstmYh...



Now set the chmod on the file:


chmod 600 authorized_keys2

Adding The Private key to PuTTY SSH authentication agent

Run the PuTTY SSH authentication agent PAGEANT.EXE. Once loaded it appears in the systray
Right-Click on it, and select Add key. Now Select your private key file, and type in your passphrase when you add the key. The Pageant works as passphrase storage.

Test Putty To Verify It Works

Open PuTTY and connect as sshtest@yourlinuxserver:

Now when you connect it should just drop you to your shell# prompt.

-Enjoy


Bookmark and Share

No comments:

Post a Comment