SSH login with private key not working

On a GL_Inet 1800AX router with firmware 4.7.0 I want to login via SSH with private key.

First I installed OpenSSH beside Dropbear as I am more familiar with the first, just another port number 2222.
I tried ssh -vv -p 2222 -i ~/.ssh/id_ed52219 -o ChallengeResponseAuthentication=yes root@IPROUTER, but it keeps asking for a password even after I added the public key id_ed52219.pub to /root/.ssh/authorized_keys' and did ssh-copy-id -p 2222 root@IPROUTER`.

Then I tried as well copying the public key via the LuCI interface for using the dropbear SSH, not OpenSSH: https://IPROUTER:8443/cgi-bin/luci/admin/system/admin/sshkeys, but to no avail.

How can I enable private key logging in ?

Hi I just tried by Lucy on: https://x.x.x.x:8443/cgi-bin/luci/admin/system/admin/sshkeys and I pasted my .pub key, it worked. I use Dropbear

Weird, for me this is not working, it still prompts for a password.
I saw that the file /etc/dropbear/authorized_keys is updated with the public key as result of adding the pubkey in the LuCI page.
This is the LuCI page for Dropbear settings:

Is here anything wrong ?

hi skatebiker,

sorry man I'm been quite busy, from your capture it seems ok from my side, but I'm been thinking how your are making your public ssh key ? cos from my side what I did... from my localcomputer (linux) I create the ssh-key by openssh and the pub key generated I copy it and paste to Glinet route from lucy dashboard (SSH-Keys menu) and that is all I done to get the access from my localhost to my router by ssh (without password)

That is what I already did, but to no avail.
Result of ssh -vvv:

debug1: Will attempt key: ecdsa-sha2-nistp256 ECDSA SHA256:XXXXXXXXXXX/YYYYYYYYYYY agent
debug1: Will attempt key: /Users/user/.ssh/id_rsa RSA SHA256:XXXXXXXXXXX/YYYYYYYYYYY
debug1: Will attempt key: /Users/user/.ssh/id_ecdsa 
debug1: Will attempt key: /Users/user/.ssh/id_ecdsa_sk 
debug1: Will attempt key: /Users/user/.ssh/id_ed25519 ED25519 SHA256:XXXXXXXXXXX
debug1: Will attempt key: /Users/user/.ssh/id_ed25519_sk 
debug1: Will attempt key: /Users/user/.ssh/id_xmss 
debug2: pubkey_prepare: done
debug1: Offering public key: ecdsa-sha2-nistp256 ECDSA SHA256:XXXXXXXXXXX/YYYYYYYYYYY agent
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: /Users/user/.ssh/id_rsa RSA SHA256:XXXXXXXXXXX/YYYYYYYYYYY
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /Users/user/.ssh/id_ecdsa
debug3: no such identity: /Users/user/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /Users/user/.ssh/id_ecdsa_sk
debug3: no such identity: /Users/user/.ssh/id_ecdsa_sk: No such file or directory
debug1: Offering public key: /Users/user/.ssh/id_ed25519 ED25519 SHA256:XXXXXXXXXXX
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /Users/user/.ssh/id_ed25519_sk
debug3: no such identity: /Users/user/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /Users/user/.ssh/id_xmss
debug3: no such identity: /Users/user/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
[email protected]'s password: 

On other servers both my ED25519 and RSA are accepted.

Found solution !!!

With dropbear, it appeared that authorized_keys had user ID 1000. I chmod'ded it to root:root and it worked !

root@glinetax1800:~# ls -al /etc/dropbear/
drwxr-xr-x    1 root     root           400 Jan  1  1970 .
drwxr-xr-x    1 root     root          3600 Apr 25 14:14 ..
-rw-------    1 root     root           854 May 23 11:08 authorized_keys
-rw-------    1 1000     1000            83 Sep  8  2023 dropbear_ed25519_host_key
-rw-------    1 1000     1000           805 Sep  8  2023 dropbear_rsa_host_key

And with openssh I also fixed it so I can use private keys.
The issue was that in /etc/ssh/sshd_config there was a line pubkeyacceptedkeytypes ssh-rsa. I commented this out and restarted sshd and could log in via openssh as well.
I run both on different ports to prevent when I am locked out on one I can use the other. Obviously they are only accessible within the LAN of the router.

2 Likes

the classic one, good job!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.