Pairhost: the ultimate EC2 remote pairing development workstation
by Stuart Sierra, http://stuartsierra.com/
Run the script
bin/ready to find out what pieces you're missing.
You'll need five things copied into this directory:
- The Amazon EC2 API tools, unzipped
- The Amazon EC2 AMI tools, unzipped
cert-*.pemfile from your Amazon Web Services account
pk-*.pemfile from your Amazon Web Services account
- The SSH private key file from your Amazon Web Services account, see below
The SSH private key file must be named
* is the name of your Amazon Web Services keypair. So, for example, if your keypair is named
my_company_key then the SSH private key file must be named
Finding and Starting Instances
bin/list to see a list of available instances. It will look like this:
ID HOSTNAME i-1a2b3c4d stopped i-a5b6c7d8 stopped
"Stopped" instances are not currently running and are therefore available for you to use.
To start an instance, run
bin/start ID where
ID is an instance ID like
i-1a2b3c4d. The instance will start and boot, which takes 10 to 30 seconds.
When your instance is ready, the script will spit out a bunch of information, including the host name.
bin/list again will also show the instance's host name.
Logging in and Joining a Terminal Session
You can SSH in as user
pair @ the host name.
If you are the first user, run
tmux to start a new shared terminal session.
If you are the second user, run
tmux attach to join the tmux session.
Opening and Closing Firewall Ports
EC2 does not use standard Linux firewalls. Instead, the firewall must be configured through the Amazon API. The script
bin/firewall makes this easier. You run this script on your local machine, not the EC2 host.
bin/firewall show to see the list of currently open ports.
bin/firewall open <port> to open a port.
bin/firewall close <port> to close it again.
Don't open ports on the remote machine, use tunnels! Run this on your local machine:
bin/tunnel <username> <hostname> <local-port> <remote-port>
<username> is "pair" and
<hostname> is the EC2 host name.
Now local-port on your local machine is tunneled to remote-port on the EC2 instance.
NX: Faster X-Windows in the Cloud
On the EC2 instance, start the NX server by running the alias
Download and install a (free) NX client for your operating system from http://nomachine.com/
From the client, initiate an NX session on the EC2 host.
Your pair starts an NX "Shadow" session on the same host, as the same user, and "attaches" to your session.
Bootstrapping New Instances from Scratch
- Launch a new instance:
When it's ready, the new instance hostname, like
ec2-123-123-123-123.compute-1.amazonaws.com will be printed.
- Bootstrap the instance:
Answer the prompts and questions as they appear.
- Perform additional setup/configuration as needed