LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Possible to keep ssh session alive even when client computer is off? (https://www.linuxquestions.org/questions/linux-newbie-8/possible-to-keep-ssh-session-alive-even-when-client-computer-is-off-911292/)

veeruk101 11-01-2011 12:42 PM

Possible to keep ssh session alive even when client computer is off?
 
I have a Linux laptop that I use to connect to a Linux server with SSH. The connection started to freeze after some inactivity, so after digging around I added the following in /etc/ssh/ssh_config (not sshd_config) on the Linux laptop:

Code:

ServerAliveInterval 60
ServerAliveCountMax 10

Now it no longer freezes, but I get the following (I think only when the laptop has been off, because the configuration above can no longer keep communicating with the server to keep the connection alive).

Code:

Timeout, server not responding.
Connection closed by xxx.xxx.xxx.xxx

Would this problem be solved if I set it to the following, because that should allow for 720 failures at 120 seconds, which equals 1440 minutes, which is a full day. Which is fine for me (if my computer is off for a full day, I'll log in again).

Code:

ServerAliveInterval 120
ServerAliveCountMax 720

Or would the server cut the connection because it's not receiving the keepalive messages from the client, because the client is off...

Alternatively, could I set the following on /etc/ssh/sshd_config on the server? Would that work?

Code:

KeepAlive yes
ClientAliveInterval 120
ClientAliveCountMax 720

I'd rather change the settings on the clients rather than the server, because I'd prefer not to have the server be sending out these messages to all the connected clients every 2 minutes to keep the connections alive. Is there some way to configure an SSH server to simply set a timeout in minutes? That would be perfect, because I'd just set the timeout on the server to be a full day, then in the clients are connected to the SSH server and are turned off, when they're turned back on within the same day they'd still be connected right? That would be exactly the outcome I'd like.

samborambo 11-01-2011 03:07 PM

Have you used the utility "screen"? It creates persistent shell sessions that can be disconnected by CTRL+A,D and reconnected by running "screen -r". If the parent ssh session is dropped, screen automatically disconnects the session and keeps it running in the background. Of course it also allows you to reconnect a shell session started from a different ssh client.

Sam.


All times are GMT -5. The time now is 02:49 PM.