Skip to content

Commit

Permalink
Added scripts for working with ssh-agent & added tmux.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Nichols committed Apr 17, 2011
1 parent 91ea986 commit 5e09d9f
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aliases
@@ -0,0 +1,2 @@
# Setup alias to source ssh variables using command 'fixssh'
alias fixssh='source ~/bin/fixssh'
12 changes: 12 additions & 0 deletions bin/Attach
@@ -0,0 +1,12 @@
#!/bin/sh
# Attach to existing ssh session

# Get new ssh vars
grabssh

# Attach to running tmux session
if [ ${1} ] ; then
tmux -L ${1} attach-session
else
tmux -L prod attach-session
fi
12 changes: 12 additions & 0 deletions bin/grabssh
@@ -0,0 +1,12 @@
#!/bin/sh
# This script grabs the ssh-agent variables from your current
# session when you login and writes them to fixssh as a
# persistent store - intended to be refreshed each time you login
SSHVARS="SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION"

for x in ${SSHVARS} ; do
(eval echo $x=\$$x) | sed 's/=/="/
s/$/"/
s/^/export /'
done 1>$HOME/bin/fixssh
chmod 600 $HOME/bin/fixssh
13 changes: 13 additions & 0 deletions bin/sc
@@ -0,0 +1,13 @@
#!/bin/sh
# Wrapper to start tmux sessions for connections to hosts

# This is a security test I like to perform - we want to show what
# ssh binary is being used to prevent any trickery
WHICH_SSH=`which ssh`

# Show only the start of the hostname.
# TODO: Make this work better with IP addresses (only shows first octet)
HOST=`echo $1|cut -d. -f1`

# Start tmux window
tmux new-window -n ${HOST} "echo 'Using: $WHICH_SSH' ; ~/bin/sc-ssh ${1}"
10 changes: 10 additions & 0 deletions bin/sc-ssh
@@ -0,0 +1,10 @@
#!/bin/sh
# This is run instead of ssh directly because it ensures that
# the correct ssh key info is sourced for this new tmux
# window

# Setup ssh-agent stuff
. $HOME/bin/fixssh

# Run ssh command
ssh -A $1
66 changes: 66 additions & 0 deletions tmux.conf
@@ -0,0 +1,66 @@
# Last modified: 2009-11-12T05:59:41+0800

# Change prefix key to Ctrl+a
unbind C-b
set -g prefix C-a

# Last active window
unbind l
bind C-a last-window
bind C-p previous-window
bind C-n next-window
bind -n f7 previous-window
bind -n f8 next-window

# Resize bindings (vim like)
bind C-k resize-pane -U
bind C-j resize-pane -D
bind C-h resize-pane -L
bind C-l resize-pane -R

# Change window move behavior
bind . command-prompt "swap-window -t '%%'"
bind > command-prompt "move-window -t '%%'"

# Copy mode
unbind [
bind Escape copy-mode
# Use Vi mode
setw -g mode-keys vi
# Make mouse useful in copy mode
#setw -g mode-mouse on

# More straight forward key bindings for splitting
unbind %
bind | split-window -h
#bind h split-window -h
unbind '"'
bind - split-window -v
#bind v split-window -v

# History
set -g history-limit 1000

# Pane
#unbind o
bind C-s down-pane

# Terminal emulator window title
set -g set-titles on
set -g set-titles-string '#S:#I.#P #W'

# Status Bar
set-option -g status-bg black
set-option -g status-fg cyan

# Notifying if other windows has activities
setw -g monitor-activity off
set -g visual-activity on

# Highlighting the active window in status bar
setw -g window-status-current-bg red
setw -g window-status-current-fg white

# Clock
setw -g clock-mode-colour green
setw -g clock-mode-style 24

0 comments on commit 5e09d9f

Please sign in to comment.