Skip to content

Instantly share code, notes, and snippets.

@zph
Created June 7, 2013 01:38
Show Gist options
  • Save zph/5726522 to your computer and use it in GitHub Desktop.
Save zph/5726522 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Make pair user and add them to the pair grp on box
### sudo adduser --disabled-password pair
# Add yourself to pair grp on box
### sudo usermod -a -G pair zander
# Setup pair user with the following /home/pair/.bash_profile
### /home/pair/.bash_profile
### https://gist.github.com/5726432
PAIR=$1
if [[ -d "/home" ]]; then
base_dir="home"; #b/c Linux is more important && standard
else
base_dir="Users"; # b/c we also use OSX
fi
# Gather github pub key and add it to pair's authkey
sudo bash -c "curl https://github.com/$PAIR.keys > /$base_dir/pair/.ssh/authorized_keys"
# Set permissions on authorized_keys
sudo chown pair:pair /Users/pair/.ssh/authorized_keys
# Setup tmux pipe, change group permissions on pipe, and join tmux
tmux -S /tmp/pair new -ds pair && chgrp pair /tmp/pair && tmux -S /tmp/pair attach -t pair
# After Tmux session ends, empty the pair's authorized_keys
sudo bash -c "echo '' > /$base_dir/pair/.ssh/authorized_keys"
# Kick pair from server
sudo pkill -9 -u pair bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment