Re: tmux... ?

157 views
Skip to first unread message

CSS

unread,
Apr 18, 2013, 12:27:38 AM4/18/13
to iterm2-...@googlegroups.com
I wish I could post via the web interface, I get email digests, so I totally end up breaking the thread when I follow-up…

Anyhow, Rick:

What I've done (and it's easy now that tmux 1.8 is out and has the iterm integration bundled in) is to install tmux on my ssh "jump hosts" that we normally use to ssh in to boxes. A jump host is generally speaking a well-secured server that accepts an ssh login from anywhere (key auth only, sshguard or fail2ban blocking abusive hosts, etc.).

From there I'll ssh in to the jump host using iterm, start tmux ('tmux -CC'), and then create all my windows and tabs for that location as new tmux sessions (look under shell->tmux in the iterm menu - there are keyboard shortcuts, but they require more dexterity than I possess). If I'm working on my laptop at home, I can simply detach the tmux session, which is done from the first iterm window I started tmux in, put my laptop to sleep, throw it in a bag and then go to a cafe or something. Once there I ssh to the jump host again, attach to my existing tmux session ('tmux -CC attach'), and all my windows and tabs magically reappear, including anything in the scroll buffer that may have gone by while I was disonnected.

It's like magic. :)

If you don't have a "jump host", you can still do something like vpn in to your network and run tmux on whatever unix host you have on your internal network and work from there.

George: I have figured out how to move a tmux tab from a window, but for the life of me I cannot figure out how to put a window back into an existing window as a tab. What am I missing?

Charles

Steve King

unread,
Apr 18, 2013, 9:46:19 AM4/18/13
to iterm2-...@googlegroups.com
On 2013-04-18 24:27 , CSS wrote:
> What I've done (and it's easy now that tmux 1.8 is out and has the iterm integration bundled in) is to install tmux on my ssh "jump hosts" that we normally use to ssh in to boxes. A jump host is generally speaking a well-secured server that accepts an ssh login from anywhere (key auth only, sshguard or fail2ban blocking abusive hosts, etc.).
>
> From there I'll ssh in to the jump host using iterm, start tmux ('tmux -CC'), and then create all my windows and tabs for that location as new tmux sessions (look under shell->tmux in the iterm menu - there are keyboard shortcuts, but they require more dexterity than I possess). If I'm working on my laptop at home, I can simply detach the tmux session, which is done from the first iterm window I started tmux in, put my laptop to sleep, throw it in a bag and then go to a cafe or something. Once there I ssh to the jump host again, attach to my existing tmux session ('tmux -CC attach'), and all my windows and tabs magically reappear, including anything in the scroll buffer that may have gone by while I was disonnected.

I do something similar, but I run tmux 1.8 on the jump host rather than
the endpoint machines. Ssh to the jump host, tmux -CC, then open new
tmux tabs on the jump host to ssh to the endpoints. Doing it this way I
can avoid installing a custom tmux build on every endpoint, I just need
the one on the jump host. (Especially important for me, since my
endpoints are often things like routers on which I *can't* install any
custom binaries.) And I can ssh to any number of different endpoints
within a single tmux session.

Here's a simple shell script wrapper for tmux to fix up sockets for ssh
agent forwarding so you don't lose that when you re-attach. Put this on
the jump host and run it instead of running tmux directly.

#!/bin/bash
# Reattach to (or spawn new if does not exist)
# tmux session "$1"

BIN="$HOME/bin/tmux"

if [ -z "$TMUX" ]; then
if [ ! -z "$SSH_TTY" ]; then
if [ ! -z "SSH_AUTH_SOCK" ]; then
ln -sf "$SSH_AUTH_SOCK" "$HOME/.wrap_auth_sock"
fi
export SSH_AUTH_SOCK="$HOME/.wrap_auth_sock"
export STY="tmux-iterm"
if $BIN has-session -t "iterm"; then
exec $BIN -CC attach-session -t "iterm"
else
exec $BIN -CC new-session -s "iterm"
fi
fi
fi


--
Steve King
Sr. Software Engineer
Arbor Networks
+1 734 821 1461
www.arbornetworks.com <http://www.arbornetworks.com/>


George Nachman

unread,
Apr 18, 2013, 2:55:00 PM4/18/13
to iterm2-...@googlegroups.com
George: I have figured out how to move a tmux tab from a window, but for the life of me I cannot figure out how to put a window back into an existing window as a tab.  What am I missing?


You can set the tab bar to always be visible in prefs>appearance so you have something to drag, then drag the tab into another window's tab bar. If you don't have split panes in a tab, you can hold down cmd+opt+shift and drag the terminal into another window's tab bar.

Aaron Meurer

unread,
Apr 18, 2013, 4:23:37 PM4/18/13
to iterm2-...@googlegroups.com, iterm2-...@googlegroups.com


On Thu, Apr 18, 2013 at 12:55 PM, George Nachman <geo...@google.com="mailto:geo...@google.com">> wrote:
George: I have figured out how to move a tmux tab from a window, but for the life of me I cannot figure out how to put a window back into an existing window as a tab. What am I missing? You can set the tab bar to always be visible in prefs>appearance so you have something to drag, then drag the tab into another window's tab bar. If you don't have split panes in a tab, you can hold down cmd+opt+shift and drag the terminal into another window's tab bar.

Why do you require these keys to be held down? Most other programs that use tabs let you just drag it in. ​
Aaron Meurer​
 -- You received this message because you are subscribed to the Google Groups "iterm2-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.

George Nachman

unread,
Apr 18, 2013, 4:47:30 PM4/18/13
to iterm2-...@googlegroups.com
To clarify, you can just drag a tab. You hold down the keys to drag a terminal view (the area where you can see text), for ex. to rearrange split panes.
Reply all
Reply to author
Forward
0 new messages