Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

how I can verify the sshd configuration ? example:

AllowUsers user1 user2 
PasswordAuthentication no
PermitRootLogin no

the only way is reading the file sshd_configuration ?

share|improve this question

closed as unclear what you're asking by MadHatter, Ward, Michael Hampton Oct 3 at 18:00

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
What do you mean by verify? Are you asking how to be sure that a config change you made is valid? Are you asking if there is some tool like lint that will check for a valid config? –  Zoredache May 18 '12 at 18:59

4 Answers 4

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 no-more-sessions@openssh.com
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.

share|improve this answer

there is no known way of querying the config of a running sshd instance, i think, if you are referring the openssh server. depending on what you want to do, you could use the -t flag to test a configuration file to make sure that it is valid before restarting the server, so that you don't get kicked out, esp. if you do not have any out-of-band access to the server.

share|improve this answer

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

share|improve this answer
1  
I don't think this answers the question he is asking, but his question isn't entirely clear. –  Zoredache May 18 '12 at 18:59
    
Looks like he's asking how to verify the configuration. As far as I'm aware, there is no way to query sshd's configuration at runtime. Thus, the configuration can only be found in the file I mentioned. –  gparent May 18 '12 at 19:18
    
Like you said, the question makes no sense so I figured maybe the OP didn't know where the file was or its exact name. –  gparent May 18 '12 at 19:18

The problem with looking at the /etc/ssh/sshd_config file as suggested by other answers is that it does not necessarily contain the whole configuration. This file contains the values of any configuration variables you want to set to over-ride the defaults, and as shipped contains as comments the defaults that are built in to sshd.

If a custom configuration file is installed in place of the shipped version, you lose sight of the defaults that are compiled in to sshd, and if it is a custom build, the defaults may not match the comments in the sshd_config that are visible.

Additionally, it is perfectly possible to run sshd with an alternate config file with the -f option, so the one stored in /etc/ssh/sshd_config may not reflect the current settings.

This makes the question quite valid, and as far as I know, unable to be answered with any certainty.

share|improve this answer
    
All of that is true, but it doesn't apply to the 99% of servers that will run sshd installed from a package that has the default configuration compiled in. –  Andrew Schulman Oct 3 at 13:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.