ssh does not use my private and public keys

Hello

I want to access from a Kimsufi Ubuntu 24.04 server to another Debian target server via SSH using public and private keys, in order to copy files from one to the other.

I generated the key pair on the client and copied the public key to the target server as usual.

It works fine, but only once. After a while a password is asked because apparently key authentication no longer works. For now I have allowed password authentication, but I obviously want to disable it.

Here is an output with

ssh -v monuser@nas

OpenSSH_9.6p1 Ubuntu-3ubuntu13.19, OpenSSL 3.0.13 30 Jan 2024
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to nas [192.168.27.70] port 22.
debug1: Connection established.
debug1: identity file /home/monuser/.ssh/id_rsa type -1
debug1: identity file /home/monuser/.ssh/id_rsa-cert type -1
debug1: identity file /home/monuser/.ssh/id_ecdsa type -1
debug1: identity file /home/monuser/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/monuser/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/monuser/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/monuser/.ssh/id_ed25519 type -1
debug1: identity file /home/monuser/.ssh/id_ed25519-cert type -1
debug1: identity file /home/monuser/.ssh/id_ed25519_sk type -1
debug1: identity file /home/monuser/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/monuser/.ssh/id_xmss type -1
debug1: identity file /home/monuser/.ssh/id_xmss-cert type -1
debug1: identity file /home/monuser/.ssh/id_dsa type -1
debug1: identity file /home/monuser/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.19
debug1: Remote protocol version 2.0, remote software version OpenSSH_9.2p1 Debian-2+deb12u6
debug1: compat_banner: match: OpenSSH_9.2p1 Debian-2+deb12u6 pat OpenSSH* compat 0x04000000
debug1: Authenticating to nas:22 as 'monuser'
debug1: load_hostkeys: fopen /home/monuser/.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: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC:  compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC:  compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:tF85nkKWqKg0GoHiZMOEM0DS/TO1m0kVQ92+KMiKp1M
debug1: load_hostkeys: fopen /home/monuser/.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 'nas' is known and matches the ED25519 host key.
debug1: Found key in /home/monuser/.ssh/known_hosts:5
debug1: ssh_packet_send2_wrapped: resetting send seqnr 3
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: ssh_packet_read_poll2: resetting read seqnr 3
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com,ssh-dss,ssh-rsa,rsa-sha2-256,rsa-sha2-512>
debug1: kex_ext_info_check_ver: publickey-hostbound@openssh.com=<0>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Will attempt key: /home/monuser/.ssh/id_rsa
debug1: Will attempt key: /home/monuser/.ssh/id_ecdsa
debug1: Will attempt key: /home/monuser/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/monuser/.ssh/id_ed25519
debug1: Will attempt key: /home/monuser/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/monuser/.ssh/id_xmss
debug1: Will attempt key: /home/monuser/.ssh/id_dsa
debug1: Trying private key: /home/monuser/.ssh/id_rsa
debug1: Trying private key: /home/monuser/.ssh/id_ecdsa
debug1: Trying private key: /home/monuser/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/monuser/.ssh/id_ed25519
debug1: Trying private key: /home/monuser/.ssh/id_ed25519_sk
debug1: Trying private key: /home/monuser/.ssh/id_xmss
debug1: Trying private key: /home/monuser/.ssh/id_dsa
debug1: Next authentication method: password
monuser@nas's password:

I have verified that the public key is still present on the target server on a line of the .ssh/authorized_keys file and that the private key is still in my .ssh folder.

I don't understand why it tries the private key /home/monuser/.ssh/id_rsa and the six following ones, while those files do not exist. They exist in /etc/ssh for the root user, but not in /home/monuser/.ssh. The key I generated has a different name, but is not being tried.

Do you have any idea what could be happening, or what I can check?

Thanks.

Hello, you can take a look at the server-side logs with journalctl -u ssh.service. If that doesn’t provide enough information, you can add LogLevel VERBOSE to sshd_config.

journalctl -u ssh.service (without adding LogLevel VERBOSE) returns:

sept. 09 12:41:33 NAS sshd[8680]: Received signal 15; terminating.
sept. 09 12:41:33 NAS sshd[2089338]: Server listening on 0.0.0.0 port 22.
sept. 09 12:41:33 NAS sshd[2089338]: Server listening on :: port 22.
sept. 09 12:41:42 NAS sshd[2089351]: Connection closed by authenticating user monuser 192.168.27.71 port 38296 [preauth]

What does this mean? Why is my OVH server sending a signal 15?

For reference, I can connect fine from other Ubuntu laptop clients and on the server we have:

sept. 09 12:47:18 NAS sshd[2089833]: Accepted publickey for monuser from 192.168.27.75 port 57576 ssh2: ED25519 SHA256:RcCaZ3DzHMG7mIQ9XemijsSPsucdCBnt5v7RRETi2KA
sept. 09 12:47:18 NAS sshd[2089833]: pam_unix(sshd:session): session opened for user monuser(uid=1000) by (uid=0)

It works by specifying the private key to use with the -i option

ssh -i .ssh/mon_certificat monuser@serveur

Why this is required on the KimSuffi server but not on other Ubuntu machines, I have no idea...