0

The process of getting Putty communicating with OpenSSH has thwarted me for quite some time.

I installed OpenSSH with:

sudo apt-get install openssh

Then I generated ssh keys with:

ssh-keygen -t rsa -b 4096 -C "my user here"

The above command moved the public and private key combo to my user's profile home .ssh directory (/home/myUser/.ssh) (I think I may have had to create the .ssh folder there in order for ssh-keygen to work properly)

Then I copied the private key to Windows and tried to use it in Putty. The server kept denying me.

2 Answers 2

2

I installed OpenSSH with:

sudo apt-get install openssh

The ssh server is in openssh-server package. SO either you do not have server installed and you are not connecting to your server or it was installed before.

The above command moved the public and private key combo to my user's profile home .ssh directory (/home/myUser/.ssh) (I think I may have had to create the .ssh folder there in order for ssh-keygen to work properly)

It generated your keys on server. But to have the keys "authorized", you need to copy the id_rsa.pub to ~/.ssh/authorized_keys`.

Then I copied the private key to Windows and tried to use it in Putty. The server kept denying me.

PuTTY does not understand the private key in OpenSSH format. You need to convert it to PuTTY format, using PuTTYgen.

Also, it is considered bad practice to move private keys around. As you are using PuTTYgen anyways, you can generate the keys on the client machine and copy just the public key to the server (apparently you still have to convert it to openssh format there: https://stackoverflow.com/a/10015651/15359441).

1

These are the steps which I used to fix the problem (I'm answering my own question because this took me two days to figure out).

  1. Go to the Windows firewall and add allow rules to port 22 inbound/outbound.

  2. Make sure to add port 22 inbound / outbound allow rules to Linux IPTABLES.

  3. Inside the /home/myUser/.ssh folder on Linux, copy the public key file (the one that has the .pub file extension) contents into a file called authorized_keys (you'll have to create it, just like you might have to create the directory "/home/myUser/.ssh" (where "myUser" is whatever your username is)

  4. Copy the private key onto the Windows box (client, where putty is installed).

  5. Go to the putty install directory on Windows (typically c:\Program Files\Putty) and run puttygen.exe. Go to the "conversions" tab and import the public key that you copied from Linux. Save it (it'll save as a .ppk file, which is Putty's key format).

  6. When you connect, in the putty left-hand side, go to "SSH", then to "Auth" - under "Auth", load the .ppk format private key you just saved. Then connect. If you're asked for a user/pass, just hit enter on both. You should be connected / see a welcome message.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .