Is there a command I can use to log out of an SSH session where I have tmux running? Currently, if I want to leave tmux running, I either close the entire window of my ssh session without logging out, or I just let the SSH connection die after inactivity.
But I want to use a command to log out without closing the entire window. If I just type logout
, then it closes my tmux session and still keeps me logged in to SSH. I then have to type logout again to close the SSH session. But I just want to type one command that disconnects SSH without closing tmux.
Is this possible?
You can also exit tmux by pressing : to go to the bottom bar of the tmux window. Then type kill-session. Note that the session will be gone and will not be reattachable. If you want to detach a session instead of simply closing it, use Ctrl-b d (d for "detach").
Detach From A Session To detach (meaning exit the window to come back to later) from the tmux session, use CTRL + b then d (hold ctrl, press b, let go of both of the keys, and press d).
In that case, you can type ~. to close the SSH session and return to your local command line terminal. This works as an escape character for SSH connections.
First press CTRL+b the press d. This detaches your session. You then press CTRL+d to log out of ssh. Your detached session still keeps running on the server. You can attach it later by tmux attach-session -t 0
when you log on to server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With