Last Updated: February 25, 2016
·
560
· jamesmartin

Inscrutable Problems With SSH Access

If you change your /etc/sshd_config and then have inscrutable problems accessing your server via ssh, try this little trick:

sudo sshd -t

From the man page:

[…] check the validity of the configuration file and sanity of the keys. This is useful for updating sshd reliably as configuration options may change.

The more you know.

Here's an inscrutable problem that I encountered recently:

$ ssh me@server
ssh_exchange_identification: Connection closed by remote host

Here's a sample of the output from a config that I screwed up:

$ sudo sshd -t
etc/sshd_config line 137: Directive 'XAuthLocation' is not allowed within a Match block

Simply fix up the problems with /etc/sshd_config and everything works again.