sshpiper icon indicating copy to clipboard operation
sshpiper copied to clipboard

Any option to auto close ssh session after some inactive time

Open sendtogeo opened this issue 4 years ago • 6 comments

Hi Team,

Thanks for this wonderful project.

Can you please update, Is there any option to close session after some inactive time Eg: 5mins of inactivity

I have checked in docs and issues and i couldn't find it.

sendtogeo avatar Nov 09 '21 20:11 sendtogeo

I think it's the job of the remote server that accept connection. So you can made it custom by customizing your sshd_config. Am I wrong ?

shiipou avatar Nov 09 '21 20:11 shiipou

Hi could you please define inactive time. per shiipou, it may refer to http://man.openbsd.org/sshd_config#ClientAliveInterval in sshd

but client can bypass it by sending empty packages.

sshpiper does not have such kind of option today, but it is easy for piper to add a timeout for pipes.

tg123 avatar Nov 09 '21 22:11 tg123

Thanks @tg123 @shiipou for your reply. Yes that will work.

We have many servers in the system and it will be difficult to set in each server. We need a feature like once inactive time set from our system, all users in sshpiper connection will auto close it when inactive time limit reached.

I will check it with code how we can implement it. It would be great If you can provide some guidelines for that code.

sendtogeo avatar Nov 10 '21 10:11 sendtogeo

To set it, you can easily create a script on a machine that can reach all servers in SSH. Use the an echo 'ClientAliveInterval=300' | sudo tee /etc/sshd_config. Or use sed command for regex if the first didn't work. This command can be executed by one of your server using a for loop in bash that connect to each ip you need and printing ip of servers that throw a connection error. I think this is the easiest way.

To configure it in sshpiper you'll need to add a timer on each connection that will be reset on each data received from the client in this file : sshpiperd/sshpiperd.go

shiipou avatar Nov 10 '21 12:11 shiipou

Thanks again for your input, I will work on sshpiperd/sshpiperd.go to implement the feature.

sendtogeo avatar Nov 10 '21 18:11 sendtogeo

PR is welcomed

tg123 avatar Nov 10 '21 20:11 tg123