0

I'm trying to connect to my home server with public key authentication, but it is failing. I have connected this way for a long time without any problem, and now it's failing, but I don't know why.

The majority of documentation I' reading in internet tells me to use ssh-keygen and ssh-copy-id and other commands like these. I'm not doing this, because I have this same key in several hosts, and it would be complicated for me to change the key everywhere - this is why I'm asking for help. I use instead a pair key generated with PuTTy in a Windows host, and the private key is password protected.

Now I'll explain my case.

Today, I have done clean-reinstall in this server which is giving me problems, in order to simplify my case and make it simpler for you guys helping me. I have installed Ubuntu 18.04.5 and then sudo apt dist-upgrade to Ubuntu 18.04.6. In the live server installer I set manually the network parameters (everything works fine) and I set it to install OpenSSH server. The server is in 192.168.1.16/24 in my local network. I have also set up zfsutils-linux and imported a ZFS pool I used in my previous installations.

Now, I connected from my Windows host with PuTTy using password authentication. I then copied my public key from puttygen (the area that says public key for pasting into OpenSSH authorized_keys file:), to an empty file under ~/.ssh/ and saved it to authorized_keys. The command is as follows:

alex@freenalex:~/.ssh$ sudo nano authorized_keys

I have always done this way with no problem. Now I checked and fixed ownership and permissions, which are as the following code:

alex@freenalex:~/.ssh$ ls -al
total 12
drwx------ 2 alex alex 4096 Jan 11 12:58 .
drwxr-xr-x 5 alex alex 4096 Jan 11 12:12 ..
-rw------- 1 alex alex  398 Jan 11 12:11 authorized_keys

Now I setup PuTTy to connect with the private key, but it shows this:

login as: alex
Server refused our key
[email protected]'s password:

I have this public key in other servers as well, and I tried today some connection examples, for example from ubuntu desktop virtual machine to the same server (I think other tries made error, but now succesfully), and from this windows machine with PuTTy to another server in my local network, with same key pair for the same user alex (sucessfully)

Maybe I have a virus? it's so strange.

I can provide more information if you ask.

Thanks in advance.

5
  • I'm curious how your authorized_keys file ended up with ownership alex alex if you created it with sudo nano - using sudo was not appropriate here. Did you chown it after? Commented Jan 11, 2022 at 15:04
  • Yes, I chown'ed the file; sorry for not being so explicit.
    – Free
    Commented Jan 11, 2022 at 16:30
  • 1
    OK so I don't see anything obviously wrong - I've never found it easy to get debug information out of PuTTY however if you're running Windows 10 you should be able to enable the native OpenSSH client and then run ssh -v / ssh -vv / ssh -vvv from a cmd.exe or PS window to see if you can see where it fails. You will likely need to export your .ppk key to OpenSSH private key via puttygen if you haven't already done so. Commented Jan 11, 2022 at 16:41
  • Hi, I have being trying to connect from cmd and it worked. Now I investigated a little bit more and I found that the connection profile I had in PuTTy had another private key than the one I used to have. Recently, trying to resolve a previous issue, I changed it, but I forgot to restore. Thanks for your help and your time.
    – Free
    Commented Jan 11, 2022 at 17:09
  • Since the answer to this is "I was using the wrong key" I have voted to close it. Commented Feb 4, 2022 at 4:09

0

You must log in to answer this question.

Browse other questions tagged .