# Keep ssh session active over tmux + no internet [SOLVED]

## audiodef

My situation: I live in the country and have no broadband - no DSL, no cable, no FIOS. So anything done online on a computer is either because I go out for WiFi or use my hotspot.

What I need to do: Find a way to ssh to my server (easy enough), and then once logged in, chroot into a stage4 and be able to detach from it (not so easy). 

The issue is that once I turn off my hotspot, there is no longer a connection from my laptop and even with tmux the connection doesn't stay active. I just need that remote chroot process to remain active to run world updates. My phone can't sit next to my laptop all the time as I need it elsewhere.

I could really use some advice on this.

----------

## pjp

Where are you running tmux?

I run tmux on a remote system. Within tmux, I have many windows, often including a chroot. I lose a connection to that remote system regularly. When I do, I ssh back to the remote system, reconnect to the tmux session. Within the tmux session, all windows remain as they were.

----------

## audiodef

Wait a minute... I get the feeling I'm using tmux wrong. I'm guessing what I *should* be doing is ssh into my server, start tmux there, then detach.

----------

## pjp

I think it might be wrong for the situation you described.

There may be a benefit to running tmux locally too, but I think the primary benefit is to run tmux where the job is being run that you don't want to die.

----------

## Ralphred

I do the same with screen instead of tmux, I do it all the time so I can reboot my admin machine without breaking package updates etc.

If your connection drops out, when it comes back reconnect to the ssh terminal, then to the screen session running in the background with screen -x. It does different "windows" too, but I've never got that far into it's controls.

----------

## audiodef

 *pjp wrote:*   

> 
> 
> There may be a benefit to running tmux locally too, but I think the primary benefit is to run tmux where the job is being run that you don't want to die.

 

This is what I meant, and that's what I figured out, thanks to your pointing me in the right direction.   :Smile: 

----------

## figueroa

 *Ralphred wrote:*   

> I do the same with screen instead of tmux, I do it all the time so I can reboot my admin machine without breaking package updates etc.
> 
> If your connection drops out, when it comes back reconnect to the ssh terminal, then to the screen session running in the background with screen -x. It does different "windows" too, but I've never got that far into it's controls.

 

I also use screen on the destination ssh shell. Just "screen" with no switches starts the session. Within screen "Ctrl/a d" detaches from the screen you are using. "screen -r" will resume it. I guess it's worked so well, I never got as far as "screen -x" reading the manual.

----------

## Ralphred

[quote="figueroa"] *Ralphred wrote:*   

> I guess it's worked so well, I never got as far as "screen -x" reading the manual.

 

Oh, that's because I use -x for remote support, you can have multiple users using the same "screen" that way. I just defaulted to using it to re-connect, muscle memory habit.

----------

