Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to log out of SSH session without closing tmux

Tags:

ssh

session

tmux

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?

like image 798
rasen58 Avatar asked Sep 12 '16 04:09

rasen58


People also ask

How do I exit tmux session without closing?

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").

How do I get out of tmux session?

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).

How do I end an ssh session?

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.


1 Answers

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.

like image 99
Atharva Parulekar Avatar answered Sep 20 '22 08:09

Atharva Parulekar