Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created August 13, 2008 08:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ELLIOTTCABLE/5213 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/5213 to your computer and use it in GitHub Desktop.
Local setup
-----------
- `NEW_SERVER_NAME='bafflement'`
- `{mkdir, cd} ~/.ec2`
- https://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key#x509
- `mv ~/Downloads/*.pem ./`
- https://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
- `cp -r /Users/elliottcable/Downloads/ec2-api-tools-1.3-19403/{bin,lib} ./`
- `ec2-add-keypair $NEW_SERVER_NAME`
- `touch id_rsa-$NEW_SERVER_NAME`
- `mate !$`
- Copy output from ec2-add-keypair
- `sudo chmod 600 id_rsa-$NEW_SERVER_NAME`
- `ec2-run-instances -k $NEW_SERVER_NAME ami-3132d758` - switch out for which AMI you want to use. This is a 32bit Arch Linux.
- `ec2-describe-instances i-e3ea348a` - wait till it's running, and remember the `ec2-*` URL
- `ec2-authorize default -p 22`
- `ec2-authorize default -p 80`
- `ec2-authorize default -P icmp -t -1:-1` - `ping`! Woot!
- Now run `host ec2-75-101-224-90.compute-1.amazonaws.com` to get the IP address for your new instance
- `ssh -i ~/.ec2/id_rsa-$NEW_SERVER_NAME root@75.101.224.90` - switch out that IP for the one returned by `host`
Instance setup
--------------
- `pacman -Syu` - What a cryptic command! Syncs the package DB and updates everything.
- `pacman -Sc` - Clean up after previous
- `rm /etc/pacman.conf ; mv /etc/pacman.conf.pacnew /etc/pacman.conf`
- `pacman -Syu` - And again!
- Now we need to merge updated `/etc/*` files - we'll use `pacdiff`, which uses `vimdiff`.
- `pacman -Sy pacman-contrib`
- Now run it! `pacdiff` - Things to watch out for in the process:
- `/etc/rc.conf` has some important settings - ensure these are set as they were originally (even if that's different from what's documented here):
- `eth0="dhcp"` - Otherwise we get no networking!
- `DAEMONS=(...... sshd)` - Otherwise we get no SSH!
- `/etc/ssh/ssh_config` make sure you're allowed to ssh into root
- `pacman -Syu` - One last time
- `pacman -Sc` - Done!
- Edit `/etc/pacman.conf` and uncomment the wget command
- `passwd` - Update the root password, not that we'll need it to SSH in.
- Now let's set a hostname
- `hostname bafflement`
- `sysctl kernel.hostname=bafflement.yreality.net`
- Quote out the 127.0.0.1 line in `/etc/hosts`, and add something of this format:
- `127.0.0.1 bafflement.yreality.net localhost.localdomain localhost bafflement`
- Fix `/etc/rc.conf`
- Hostname (to complete above hostname steps): `HOSTNAME="$NEW_SERVER_NAME"`
- `USECOLOR="no"` - Screws with `ec2-get-console-output`
- `TIMEZONE="America/Anchorage"`
- Now exit the SSH instance, and let's reboot the server. `ec2-reboot-instances i-e3ea348a` - you can use `ec2-get-console-output` to monitor the status of the reboot
- SSH in again - `ssh -i ~/.ec2/id_rsa-$NEW_SERVER_NAME root@75.101.224.90`
- `useradd -m -s /bin/bash -c "elliottcable" elliottcable && chown elliottcable /home/elliottcable && passwd elliottcable`
- `visudo` and add yourself to the file, or set wheel as all/all/all
- `gpasswd -a elliottcable wheel`
- `su - elliottcable`
- Set up SSH for your own user, so you can stop logging in to root
- `{mkdir,chmod 700} ~/.ssh`
- `{touch,chmod 400} ~/.ssh/authorized_keys`
- Locally on every computer you want to SSH into the instance from, run the following:
- `ssh_keygen -t rsa`
- Then copy the contents of `~/.ssh/id_rsa.pub` (on the local system) to `~/.ssh/authorized_keys` (on the instance)
- Now you can SSH in from yourself, or you should be able to: `ssh elliottcable@75.101.224.90`
Server setup
------------
- If you need to build and install stuff manually:
- `sudo pacman -Sy base-devel`
- `sudo pacman -S abs`
- `sudo mkdir -p /usr/local/pkg`
- Edit `/etc/makepkg.conf` and change `PKGDEST=/usr/local/pkg`
- `sudo cp -r /var/abs/extra/git /var/abs/local/my_cooler_git ; cd $!`
- ... # Maybe more here later, balls if I know.
- Profit!
- `sudo pacman -S ruby rubygems`
- `sudo gem install rake `
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment