Koozali.org: home of the SME Server

sshd, reject new connections, but let existing finish

Offline loejf

  • ****
  • 74
  • +0/-0
sshd, reject new connections, but let existing finish
« on: December 17, 2009, 03:33:42 PM »
Hi.
Does anyone know, if it is possibled on sme 7.4 openssh dæmon, to reject new ssh connections, and at the same time let existing connections finish. So you can have a schedule without connections??

Loejf
...

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: sshd, reject new connections, but let existing finish
« Reply #1 on: December 17, 2009, 03:48:14 PM »
please explain your probkem/what you are trying to achieve, not tha solution ;-)

Offline loejf

  • ****
  • 74
  • +0/-0
Re: sshd, reject new connections, but let existing finish
« Reply #2 on: December 17, 2009, 05:20:02 PM »
Hi.
The problem is, that we do have a lot of ssh connections to our server, and we are not able to manage those connections. When we for maintenance options ex. wants to reboot or alike, we want to do it, when there are no open connections, but we dont want to cut of existing connections, but wait for them to finish, and therefore we dont want any new connections in the meantime.

Loejf
...

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: sshd, reject new connections, but let existing finish
« Reply #3 on: December 17, 2009, 06:17:30 PM »
Hi.
The problem is, that we do have a lot of ssh connections to our server, and we are not able to manage those connections. When we for maintenance options ex. wants to reboot or alike, we want to do it, when there are no open connections, but we dont want to cut of existing connections, but wait for them to finish, and therefore we dont want any new connections in the meantime.

Loejf

many users connected via ssh to a console or just for ssh tunnels?

if the first, you can send a wall message to everybody to disconnect

Offline loejf

  • ****
  • 74
  • +0/-0
Re: sshd, reject new connections, but let existing finish
« Reply #4 on: December 17, 2009, 06:29:07 PM »
clients using sftp.

No wall message possible. The clients connect by scripting, and automatically.
In connection rejected, they will try again later.
...

Offline mmccarn

  • *
  • 2,651
  • +10/-0
Re: sshd, reject new connections, but let existing finish
« Reply #5 on: December 18, 2009, 05:01:36 PM »
Before the ssh port could be set in server-manager I wrote wiki instructions on changing it manually.

At that time (SME 7.1.3 / 7.2), changing the port would leave existing connections "up", while forcing new connections to use the new port.

That is, I could *remotely* connect to sshd on port 22, change the port to 222, connect to sshd on port 222 and still have two connections open (the original on 22 and the new one on 222).

You may be able to use this to your advantage; my notes/instructions can be found at http://wiki.contribs.org/SSH_Port#Annotated_Version_.28same_as_.22Summary_Version.22.2C_but_with_explanations_.26_verification.29

Offline loejf

  • ****
  • 74
  • +0/-0
Re: sshd, reject new connections, but let existing finish
« Reply #6 on: December 18, 2009, 09:46:34 PM »
Hi.
Thank you very much.
That could be a way of doing it. Temporarily changing the port, do the stuff, and then turn the original back on.
And done by scripting, it should be a thing to overcome.
Loejf
...