This tutorial is about remotely logging in to your server or seedbox using public key authentication. The procedure is more secure as oppose to supplying your password when you create a new ssh/sftp session. I know some of you hate typing your long, complicated, and boring password everytime you connect to your server- well, this tutorial eliminates that step. Additionally, it is useful in situations where you need to automate certain tasks such as running a shell script or a cronjob.

The concept of public key authentication is straight forward-- you have two keys: Public and Private. You keep the private key to your PC and copy the public key to your server/seedbox. You need to keep the private key in a safe place. It can go bad if someone gets access to your private key as it will be easy for the perpetrator to access your server/seedbox.
There will be three parts to this tutorial. The first part is the creation of Private and Public keypairs. Second, is to configure and use them with PuTTY. Third, configure FileZilla to use public key authentication.

Tools that you will need:
PuTTY - http://the.earth.li/~sgtatham/putty/.../x86/putty.exe
PuTTYgen - http://the.earth.li/~sgtatham/putty/...6/puttygen.exe
FileZilla - http://downloads.sourceforge.net/fil...in32-setup.exe


Part 1: Creating the Public and Private keypair

Run puttygen.exe
Select SSH-2 RSA as the type of key
Enter '2048' as the number of bits
Click on 'Generate' button
Move your mouse pointer over the blank area while puttygen.exe generates a keypair
Click on 'Save public key' button. Name the file appropriately
Click on 'Save private key' button. Name the file appropriately
Note: If you are prompted about passphrase when saving the private key, just select yes. Private key file should have .ppk extension while Public key file doesn't need to have any.

We now copy the Public key file to the server.

Fire up FileZilla and connect to your server via FTP or SFTP, whichever you prefer.
Upload your public key file to /home/YOUR_USERNAME/.ssh directory (Create .ssh dir if it doesn't exist)
Rename the public key file to 'authorized_keys'
You can now close both puttygen.exe and FileZilla


Part 2: Configuring PuTTY for public key authentication

Run PuTTY
We will create a new Session in PuTTY Configuration
Select 'Session' from the Category
Enter your server's host name or IP address, ssh port number, and a name to save the session
Click on 'Save' button
Select 'Data' under connection category
Enter your server user name in the 'Auto-login username' textbox
Click on 'Auth' under Connection->SSH category
Click on 'Browse' button and locate your Private key generated from puttygen.exe
Click 'Open'
Go back and click 'Session' Category
Click 'Save' again
Now, we're ready to connect!
Click 'Open'
Congratulations! You should now be able to SSH connect to the server without entering your password!


Part 3: Configuring FileZilla for public key authentication

Run FileZilla
Select Edit->Settings from the Settings page, select SFTP under Connection category
Click 'Add keyfile'
Locate your Private key file
Click OK
Click on Site Manager icon
Create a New Site
In 'General' tab
Enter Host and Port number
Select SFTP - SSH File Transfer Protocol
Select Normal
Enter your server user name
LEAVE THE PASSWORD FIELD BLANK
Click 'Connect'
Congratulations! You should now be able to SFTP connect to the server without entering your password!

What if it doesn't work?

Check the /etc/ssh/sshd_config and make sure the following lines are not commented:
RSAAuthentication yes
PubkeyAuthentication yes