Score:0

Is there a way to edit sshd_config without disabling it and enabling again?

la flag

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.

Score:0
vn flag

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, man sshd_config, and man systemctl.

waltinator avatar
it flag
Another trick I've used in my 60+ year sysadmin/security career is to queue an `at` job that restores the original (working) configuration for "now +15 minutes". If the new configuration works, I have 15 minutes to log back in and cancel the `at` job. This method, obsessedly applied, has bailed me out of several risky, remote, emergency middle-of-the night "events".
Kamiszewskyy avatar
la flag
Alright, thanks for you answers! Anyway, I have another question about ssh. How much bandwidht does remote port forward use? I'm thinking about making a game server like minecraft or factorio etc. So for example I would have 3 ssh remote port forward for 24/7 and how much bandwidth would they use? Will they use the same amount of bandwidth what players uses on servers as I'm forwarding them?
Amos avatar
vn flag
Thanks for that tip, @walternator
Amos avatar
vn flag
@Kamiszewskyy If you were happy with my answer to your original question, please accept it. If you have other questions, you should use the Ask Question button again so the site can do its thing.
Kamiszewskyy avatar
la flag
Alright, my bad
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.