Skip to content

Instantly share code, notes, and snippets.

@michaeldever
Last active July 25, 2017 11:11
Show Gist options
  • Save michaeldever/3ec33d7bb682fcc2620202d87f4fe604 to your computer and use it in GitHub Desktop.
Save michaeldever/3ec33d7bb682fcc2620202d87f4fe604 to your computer and use it in GitHub Desktop.
Gemstash User Setup
# Set permissions on the keypair
chmod 600 gemstash.pem
# SSH into the Gem Server
ssh -i gemstash.pem ubuntu@$GEMSERVER_IP
# Make sure your Gem Server is up to date
sudo apt-get update && sudo apt-get -y upgrade
# Create a gemstash user
sudo useradd -d /home/gemstash -m gemstash
# Set the gemstash users password
sudo passwd gemstash
# Add gemstash to the pool of root users
# Insert the following: gemstash ALL=(ALL:ALL) ALL
sudo visudo
# Change user to gemstash
su - gemstash
# Create gemstash directory
mkdir -p ~/.gemstash
# Create an SSH key for gemstash - replace SOME COMMENT with your e-mail or some other identifier.
ssh-keygen -t rsa -C 'SOME COMMENT'
# Print the newly created public key. Copy this and add it as an SSH key on GitHub/BitBucket.
cat ~/.ssh/id_rsa.pub
### Break Start - Setup passwordless access to the gemserver for your local machine:
# On your own machine, print your own and copy this.
cat ~/.ssh/id_rsa.pub
# As the gemstash user on your gemserver, add your own key into the following
vi ~/.ssh/authorized_keys
# Test your passwordless access to the gemserver on your own machine:
ssh gemstash@$GEMSERVER_IP
### Break End - The following is run on your gemserver
# Setup the necessary libraries
sudo apt-get install git ruby2.3-dev zsh
# Change shell for gemstash
sudo chsh -s /bin/zsh gemstash
# Install RVM (or setup RBENV or whatever you use)
\curl -sSL https://get.rvm.io | bash -s stable
source ~/.bash_profile
# Install a version of ruby
rvm install 2.3.4
rvm use 2.3.4 --default
# Install bundler
gem install bundle
# Setup Routing, this will route all requests from port 80 (HTTP) and 443 (HTTPS) to port 8080
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 8080
# Persist IP Tables, choose to keep existing rules.
sudo apt-get install iptables-persistent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment