Introduction: Creating SSH Keys

Picture of Creating SSH Keys

In this Tutorial you get to learn how to generate ssh keys using puTTYgen and how to launch puTTY using Windows batch. Tested on Raspberry Pi 2 and Windows 7.

Step 1: Downloads

Picture of Downloads

Step 2: Pre Key Setup on Server

Login to your Pi using Putty.
Navigate into your account home directory.
mkdir -p .ssh; touch .ssh/authorized_keys

Step 3: Generate a New Key

Picture of Generate a New Key

Run puTTYgen to generating a new key.
You need to select which type of key you want to generate, and also select the strength of the key.
Then press the Generate button, to actually generate the key.
Once you have generated the key, select a comment field and a passphrase. if you want to type a passphrase every time( I don't)
Now you’re ready to save the private key to disk; press the Save private key button. (it should end in ppk)
Under Key you should see a lot of random text.
Right click and "select all" and "Copy" it into your buffer.

Step 4: Adding Key to Your Server

Login to your server.
Navigate into your account home directory.
Once there, we are going to echo the key into your authorized_keys file.
echo "YOUR VERY VERY LONG KEY THAT WAS IN YOUR BUFFER" >> .ssh/authorized_keys

Your key pair is now ready for use.
Logout of your server

Step 5: Optional Setup a One Click Batch File to Login

Picture of Optional Setup a One Click Batch File to Login

Open the WinPuttyHelper.rar file.
copy post_login_cmds.txt & setup.bat

After setup is completed you can remove "-m post_login_cmds.txt" from the bat file it generates and it will auto login without logging out of your server.

Why is using SSH key more secure than using passwords?SSH keys are long and complex, far more than any password could be. But they don't expire, and they sit on a disk where they can be stolen from. On the other hand, they don't get transmitted to the remote system (except key forwarding, use Sneakernet ) which passwords need to be. Passwords are generally, predictably, unavoidably weak. While it is possible to have strong passwords, time and again it has been shown that people will use weak passwords and have poor password practices... short, simple, word-based, simple patterns ("p@ssw0rd!"), write them down, use them on multiple sites, base them on their phone number, their children's birthdate, their own name. You point out that keys don't expire, but why do passwords expire? To ensure that a brute-force attack is less likely to crack a password before it's been replaced. Not an issue that impacts keys.And, bad passwords aside, even "good" passwords are vulnerable to brute-force (online or offline) under the right conditions. They have to get transmitted to the other system, or to any other place that the user can be fooled into sending them by mistake.The balance of evidence strongly suggests that passwords are weaker and keys are stronger. - gowenfawr

For more info please check out


nodnodwinkwink (author)2017-03-20

Hey nfarrow, I'm pretty new to this and know very little about linux or ssh so please bear with me.

I'm using ubuntu core on a pi 3 and have connected it to my network with a lan cable. When I try to logon with my email on the pi 3 it says "no ssh keys found".

I know I need the ssh key to proceed but I'm getting stuck at the logon stage after connecting with putty.

I've tried pi as the username with a variety of passwords. I've tried ubuntu for username and password. I've tried leaving them blank but none are accepted...

Is there some other default logon area that I'm missing? Thanks

nfarrow (author)nodnodwinkwink2017-03-20

Log on without using a ssh key and check if you see the .ssh folder in /home/ path.
use, "ls -ltrh" since .ssh folder would be hidden.

Either way I would recommend deleting the .ssh folder content and regenerating the keys and rerunning the commands.

nfarrow (author)nfarrow2017-03-20

Also the default login for a Pi is

USER: pi

PASS: raspberry