Is there a way to edit sshd_config without disabling it and enabling again?
so I would like to know if there is any way to edit sshd_config without disabling it, then enabling it? I’m asking because I want to create a few Match User options but I don’t want to disable it because it is going to close my connections.
If not, is there any other way to remote port forward? I want to allow a specific user to connect to server via ONLY ONE SPECIFIC PORT in the ssh server.
From the info you provided, I am assuming you are connected in to a terminal on the remote system and are working on the command line.
You can edit the /etc/ssh/sshd_config file to make your changes. Nothing will take effect until you have sshd reload the configuration. I suggest making a backup copy of that file before editing it.
Test your changes by running
sudo sshd -t in a terminal and if it gives you errors, fix them until that command doesn’t return any issues. When you are happy that your changes aren’t going to break anything, you can run
sudo systemctl reload sshd or
sudo systemctl restart sshd. Your existing sessions should remain active until you close them. Although I am not sure that will be the case if your sshd_config changes would introduce rules preventing your current connection being re-established. If you figure that out, please comment on this answer and let me know!
And if you need to stop and start services, use
sudo systemctl stop ... and
sudo systemctl start ... not disable and enable. Those do different things.
When you want to learn a bit more and see where I found the answer for you, run and read the output of
man sshd_config, and