tmux: session initialization
use case: you need to connect to multiple hosts at once and leave the connections active even as you log out from the entry node.
network layout:
- remote machine (e.g., laptop at home)
- entry node (ssh gateway at work)
- has
tmuxinstalled
- has
- multiple compute nodes
workflow for tmux session creation (only done once)
sshinto entry node- start
tmuxsession (see config script below):$ tmux source ~/.tmux/nodes \; attach - detach
workflow if tmux session is already started
sshinto entry node- attach
tmuxsession - select
tmuxpane/compute node - run your stuff
- detach
- reattach session, ...
tmux config script to create a session with a 2x4 splitted terminal setup. upper row is logged into node{1..4} and changed into working directory. the lower row is logged into node{1..4} and shows stats using top.
[code language=text]
$ cat ~/.tmux/nodes
new-session -s nodes "ssh -t node1 'cd $SRC; zsh'"
split-window -h "ssh -t node3 'cd $SRC; zsh'"
split-window -h -t 0.0 -p 50 "ssh -t node2 'cd $SRC; zsh'"
split-window -h -t 0.2 -p 50 "ssh -t node4 'cd $SRC; zsh'"
split-window -v -t 0.0 "ssh -t node1 top"
split-window -v -t 0.2 "ssh -t node2 top"
split-window -v -t 0.4 "ssh -t node3 top"
split-window -v -t 0.6 "ssh -t node4 top"
[/code]