SSH login does not work

Hi,

When I try to login to the router using ssh like,

ssh admin@10.0.10.1

It asks me for a password even though I have saved my rsa4096 public key on the router for pub key based authentication and it denies access even when I enter the correct password in the password prompt.

Running Router OS 7.2 on RB450GX4

SSH Client logs

emerald :: ~ 130 » ssh admin@10.0.10.1 -v
OpenSSH_9.0p1, OpenSSL 1.1.1n  15 Mar 2022
debug1: Reading configuration data /home/ishan/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 10.0.10.1 [10.0.10.1] port 22.
debug1: Connection established.
debug1: identity file /home/ishan/.ssh/id_rsa type 0
debug1: identity file /home/ishan/.ssh/id_rsa-cert type -1
debug1: identity file /home/ishan/.ssh/id_ecdsa type -1
debug1: identity file /home/ishan/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/ishan/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/ishan/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/ishan/.ssh/id_ed25519 type 3
debug1: identity file /home/ishan/.ssh/id_ed25519-cert type -1
debug1: identity file /home/ishan/.ssh/id_ed25519_sk type -1
debug1: identity file /home/ishan/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/ishan/.ssh/id_xmss type -1
debug1: identity file /home/ishan/.ssh/id_xmss-cert type -1
debug1: identity file /home/ishan/.ssh/id_dsa type -1
debug1: identity file /home/ishan/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.0
debug1: Remote protocol version 2.0, remote software version ROSSSH
debug1: compat_banner: no match: ROSSSH
debug1: Authenticating to 10.0.10.1:22 as 'admin'
debug1: load_hostkeys: fopen /home/ishan/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: rsa-sha2-256
debug1: kex: server->client cipher: aes192-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes192-ctr MAC: hmac-sha2-256 compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_GROUP received
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: SSH2_MSG_KEX_DH_GEX_REPLY received
debug1: Server host key: ssh-rsa SHA256:KKD/WvxNLldsCXCYc+y8vpH5+RKe7KJOFGrscT1YINM
debug1: load_hostkeys: fopen /home/ishan/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '10.0.10.1' is known and matches the RSA host key.
debug1: Found key in /home/ishan/.ssh/known_hosts:521
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: /home/ishan/.ssh/id_rsa RSA SHA256:DleBQCfe4peOIbPb9fDH5zH5Mhp5tKv8xX0q6sK2Ry4
debug1: Will attempt key: /home/ishan/.ssh/id_ecdsa
debug1: Will attempt key: /home/ishan/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/ishan/.ssh/id_ed25519 ED25519 SHA256:jkaawS19mnw4U4Ub9Al6/lqBI2QCRzWpQgMJiMsMTnc
debug1: Will attempt key: /home/ishan/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/ishan/.ssh/id_xmss
debug1: Will attempt key: /home/ishan/.ssh/id_dsa
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/ishan/.ssh/id_rsa RSA SHA256:DleBQCfe4peOIbPb9fDH5zH5Mhp5tKv8xX0q6sK2Ry4
debug1: send_pubkey_test: no mutual signature algorithm
debug1: Trying private key: /home/ishan/.ssh/id_ecdsa
debug1: Trying private key: /home/ishan/.ssh/id_ecdsa_sk
debug1: Offering public key: /home/ishan/.ssh/id_ed25519 ED25519 SHA256:jkaawS19mnw4U4Ub9Al6/lqBI2QCRzWpQgMJiMsMTnc
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/ishan/.ssh/id_ed25519_sk
debug1: Trying private key: /home/ishan/.ssh/id_xmss
debug1: Trying private key: /home/ishan/.ssh/id_dsa
debug1: Next authentication method: password
admin@10.0.10.1's password:

This is related to, http://forum.mikrotik.com/t/openssh-future-rsa-host-key-deprecation/136874/1

  1. ed25519 does not work at all since I can’t import ed25519 keys.
  2. I can’t connect to mikrotik from my machines because host key used my mikrotik is ssh-rsa.

So, Password OR pub key auth does not work.

The temporary fix for this is to add,

Host <ros-ip>
        PubkeyAcceptedKeyTypes +ssh-rsa