verify sshd configuration

How I can verify the configuration of sshd?

For example, I want to make sure that these settings are set and applied:

AllowUsers user1 user2 
PasswordAuthentication no
PermitRootLogin no

Is the only way manually verifying the contents of the file sshd_config, or can I probe sshd to make sure?


There is an extended test mode, invoked with the command line option -T, which does this. For example:

% sudo sshd -T | egrep -i 'allowusers|passwordauth|permitroot'
permitrootlogin yes
passwordauthentication yes

The option has existed in Portable OpenSSH since 2008, cf. commit e7140f2. This was released with 5.1p1, made in July 2008, cf. release notes for 5.1, so it exists in pretty much all OpenSSH server installations supported today.


sshd's configuration is typically found in the following file: /etc/ssh/sshd_config.

To query the runtime configuration, you can use extended test mode sshd -T which also allows you to test client matching of settings.


While this won't dump all your server definitions, you can try connecting to the server with a verbose debug flag: ssh -v user@server. That will give you a lot of information that will reflect the options enabled in sshd configuration.

For example, take a look on the output of this connection with the -v switch (key signatures, domain and IP addresses purposely disguised):

OpenSSH_6.0p1, OpenSSL 0.9.8w 23 Apr 2012
debug1: Reading configuration data /home/claudio/.ssh/config
debug1: /home/claudio/.ssh/config line 13: Applying options for serv01
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to somedomain.com [185.113.29.221] port 22.
debug1: Connection established.
debug1: identity file /home/claudio/.ssh/id_dsa type 2
debug1: identity file /home/claudio/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9
debug1: match: OpenSSH_5.9 pat OpenSSH_5*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 3a:0d:b8:18:ca:67:4c:54:0f:c8:b2:1e:48:53:69:28
debug1: Host '[somedomain.com]:22' is known and matches the ECDSA host key.
debug1: Found key in /home/claudio/.ssh/known_hosts:7
Warning: Permanently added the ECDSA host key for IP address '[185.113.29.221]:22' to the list of known hosts.
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering DSA public key: /home/claudio/.ssh/id_dsa
debug1: Server accepts key: pkalg ssh-dss blen 433
debug1: Authentication succeeded (publickey).
Authenticated to somedomain.com ([185.113.29.221]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.

From that you can see the allowed authentication methods are: publickey,password,keyboard-interactive. You can also see that roaming is not allowed by this server, and that user claudio could connect using his public key.

You can increase the level of information output specifying more "v" letters, but then you may get way more low level information than you probably want.