I recently misconfigured an ssh file while messing with ciphers, knocking down remote control until I could access the computer locally and fix it. I was wondering if there was a way to prevent this type of problem in the future by running a script to replace the sshd_config file with a "safe" version upon a signal (non-ssh, obviously) being sent. I can write the script, what I'm looking for is a way to execute it remotely, with as little extra software as possible. I've previously set up something like this using apache to host php that runs bash scripts, but it seems to me that there should be a more elegant solution. This is relatively secure, assume that security won't be an issue. Thanks!

  • Screw around on a local virt first, and then when you've got things squared away there go mess with the hard-to-get-to-host.
    – thrig
    Commented Apr 28, 2017 at 22:36
  • @thrig I work from a Chromebook. Not a lot of room for vms.
    – brndn2k
    Commented Apr 28, 2017 at 22:55

2 Answers 2


One brute force option is to start a second SSH server running on a different port. If you screw up the "main" one, just log in on the backup.

Obviously remember to disable the backup once you've finished testing :-)

  • This feels a little roundabout, but it'll also work perfectly. Thanks!
    – brndn2k
    Commented Apr 30, 2017 at 15:53

General workflow is to change the configuration, restart the sshd service and test the connection, before you close the existing connection. If you screwed the configuration, scan through the logs, revert the configuration, restart the service again to get back to working state.

Restarting the sshd service does not close nor affect earlier opened sessions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .