LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   SSH Remote Access - Testing (https://www.linuxquestions.org/questions/linux-server-73/ssh-remote-access-testing-4175736368/)

JJJCR 04-24-2024 02:27 AM

SSH Remote Access - Testing
 
Hi guys, how do you revert settings for SSHD on remote VMs? in order not to be locked out if something goes wrong.

- sshd -T >> will check if config is ok or not, before exiting the VM.

Is there a way to revert the original settings after a certain time? just as a back up, if really some unforeseen circumstances that will pop-up and not able to SSH

Thanks.

Turbocapitalist 04-24-2024 02:46 AM

One way is to fire up a parallel instance of the SSH daemon on a second port, but otherwise using all the same settings. You'd obviously need some other port open at least temporarily or use a bastion or jump host:

Code:

sudo /usr/sbin/sshd -p 2222

# or

sudo /usr/sbin/sshd -p 2222 -f /root/some.test.configuration.file

The command line arguments override the configuration file, so you can add more options that way, too.

Another way is to save the working configuration and set an at job to restore it + reload it in the daemon after a number of minutes. That way, if you can get back in you can cancel the at job but if you can't get back in, if you set up the job correctly, you can get back in. That can certainly be used with firewall / packet filter settings, too.

I'd go with the -p option myself.

pan64 04-24-2024 02:47 AM

you can set a crontab or something similar to overwrite the config and restart sshd if you wish.


All times are GMT -5. The time now is 03:14 PM.