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/>