---
title: "BASH : Comment débugger un problème SSH côté serveur ?"
canonical: "https://blog.kaptus.net/space/BKAP/blog/166395907/BASH%20%3A%20Comment%20d%C3%A9bugger%20un%20probl%C3%A8me%20SSH%20c%C3%B4t%C3%A9%20serveur%20%3F"
format: markdown
---
## Problème

Comment débugger un problème de connexion ssh côté serveur ?

## Solution

Il suffit de lancer le serveur sshd en mode débug sur un port spécifique :

```shell
/usr/sbin/sshd -p 2222 -d
```

> ✅ debug1: sshd version OpenSSH_7.9, OpenSSL 1.1.1d 10 Sep 2019  
> ✅ debug1: private host key #0: ssh-rsa SHA256:0tyjYDs+qXFLy0xES3WrN9VsMXndrLeDGyQlRSclvbQ  
> ✅ debug1: private host key #1: ecdsa-sha2-nistp256 SHA256:pAte8iSmv8/XjpWlaEQ/ZcqeU9K5p8bEDtvYlpWYTZw  
> ✅ debug1: private host key #2: ssh-ed25519 SHA256:1k9ccp+epCjD0lb8UKubSjWp5BiXWkdRBitGs3Qz8Lo  
> ✅ debug1: rexec_argv[0]='/usr/sbin/sshd'  
> ✅ debug1: rexec_argv[1]='-p'  
> ✅ debug1: rexec_argv[2]='2222'  
> ✅ debug1: rexec_argv[3]='-d'  
> ✅ debug1: Set /proc/self/oom_score_adj from 0 to -1000  
> ✅ debug1: Bind to port 2222 on 0.0.0.0.  
> ✅ Server listening on 0.0.0.0 port 2222.  
> ✅ debug1: Bind to port 2222 on ::.  
> ✅ Server listening on :: port 2222.  
> ✅ debug1: Server will not fork when running in debugging mode.  
> ✅ debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8  
> ✅ debug1: inetd sockets after dupping: 3, 3  
> ✅ Connection from 77.140.85.93 port 61777 on 212.129.31.20 port 2222  
> ✅ debug1: Client protocol version 2.0; client software version OpenSSH_7.8  
> ✅ debug1: match: OpenSSH_7.8 pat OpenSSH* compat 0x04000000  
> ✅ debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u1  
> ✅ debug1: permanently_set_uid: 106/65534 [preauth]  
> ✅ debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]  
> ✅ debug1: SSH2_MSG_KEXINIT sent [preauth]  
> ✅ debug1: SSH2_MSG_KEXINIT received [preauth]  
> ✅ debug1: kex: algorithm: curve25519-sha256 [preauth]  
> ✅ debug1: kex: host key algorithm: ecdsa-sha2-nistp256 [preauth]  
> ✅ debug1: kex: client->server cipher: [chacha20-poly1305@openssh.com](mailto:chacha20-poly1305@openssh.com) MAC: <implicit> compression: none [preauth]  
> ✅ debug1: kex: server->client cipher: [chacha20-poly1305@openssh.com](mailto:chacha20-poly1305@openssh.com) MAC: <implicit> compression: none [preauth]  
> ✅ debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]  
> ✅ debug1: rekey after 134217728 blocks [preauth]  
> ✅ debug1: SSH2_MSG_NEWKEYS sent [preauth]  
> ✅ debug1: expecting SSH2_MSG_NEWKEYS [preauth]  
> ✅ debug1: SSH2_MSG_NEWKEYS received [preauth]  
> ✅ debug1: rekey after 134217728 blocks [preauth]  
> ✅ debug1: KEX done [preauth]  
> ✅ debug1: userauth-request for user prevoir service ssh-connection method none [preauth]  
> ✅ debug1: attempt 0 failures 0 [preauth]  
> ✅ debug1: user prevoir matched group list sftponly at line 136  
> ✅ debug1: PAM: initializing for "prevoir"  
> ✅ debug1: PAM: setting PAM_RHOST to "77.140.85.93"  
> ✅ debug1: PAM: setting PAM_TTY to "ssh"  
> ✅ debug1: userauth-request for user prevoir service ssh-connection method publickey [preauth]  
> ✅ debug1: attempt 1 failures 0 [preauth]  
> ✅ debug1: userauth_pubkey: test pkalg rsa-sha2-512 pkblob RSA SHA256:mL0EBxk5nsvTSQRe1lR8BEuZEv7wGSPpLPhBJF5w4IE [preauth]  
> ✅ debug1: temporarily_use_uid: 1005/1005 (e=0/0)  
> ✅ debug1: trying public key file /opt/naos/users/prevoir/.ssh/authorized_keys  
> ✅ debug1: Could not open authorized keys '/opt/naos/users/prevoir/.ssh/authorized_keys': No such file or directory  
> ✅ debug1: restore_uid: 0/0  
> ✅ debug1: temporarily_use_uid: 1005/1005 (e=0/0)  
> ✅ debug1: trying public key file /opt/naos/users/prevoir/.ssh/authorized_keys2  
> ✅ debug1: Could not open authorized keys '/opt/naos/users/prevoir/.ssh/authorized_keys2': No such file or directory  
> ✅ debug1: restore_uid: 0/0  
> ✅ Failed publickey for prevoir from 77.140.85.93 port 61777 ssh2: RSA SHA256:mL0EBxk5nsvTSQRe1lR8BEuZEv7wGSPpLPhBJF5w4IE  
> ✅ debug1: userauth-request for user prevoir service ssh-connection method publickey [preauth]  
> ✅ debug1: attempt 2 failures 1 [preauth]  
> ✅ debug1: userauth_pubkey: test pkalg ssh-ed25519 pkblob ED25519 SHA256:0p6glDFVNMo5pF4wnMAOcdF0gdIGjTWIgNu6rusBSMU [preauth]  
> ✅ debug1: temporarily_use_uid: 1005/1005 (e=0/0)  
> ✅ debug1: trying public key file /opt/naos/users/prevoir/.ssh/authorized_keys  
> ✅ debug1: Could not open authorized keys '/opt/naos/users/prevoir/.ssh/authorized_keys': No such file or directory  
> ✅ debug1: restore_uid: 0/0  
> ✅ debug1: temporarily_use_uid: 1005/1005 (e=0/0)  
> ✅ debug1: trying public key file /opt/naos/users/prevoir/.ssh/authorized_keys2  
> ✅ debug1: Could not open authorized keys '/opt/naos/users/prevoir/.ssh/authorized_keys2': No such file or directory  
> ✅ debug1: restore_uid: 0/0  
> ✅ Failed publickey for prevoir from 77.140.85.93 port 61777 ssh2: ED25519 SHA256:0p6glDFVNMo5pF4wnMAOcdF0gdIGjTWIgNu6rusBSMU  
> ✅ debug1: userauth-request for user prevoir service ssh-connection method password [preauth]  
> ✅ debug1: attempt 3 failures 2 [preauth]  
> ✅ debug1: PAM: password authentication accepted for prevoir  
> ✅ debug1: do_pam_account: called  
> ✅ Accepted password for prevoir from 77.140.85.93 port 61777 ssh2  
> ✅ debug1: monitor_child_preauth: prevoir has been authenticated by privileged process  
> ✅ debug1: monitor_read_log: child log fd closed  
> ✅ debug1: PAM: establishing credentials  
> ✅ User child is on pid 8074  
> ✅ debug1: SELinux support disabled  
> ✅ debug1: PAM: establishing credentials  
> ✅ <span style="color: #bf2600">**bad ownership or modes for chroot directory component "/opt/naos/"**</span>  
> ✅ debug1: do_cleanup  
> ✅ debug1: do_cleanup  
> ✅ debug1: PAM: cleanup  
> ✅ debug1: PAM: closing session  
> ✅ debug1: PAM: deleting credentials  
> ✅ debug1: audit_event: unhandled event 12

## Articles connexes

> Macro (contentbylabel)