Hey! I'm available for hire (and I appreciate tips)  



My VPS providers of choice

I like http://digitaloceancom and http://thrustvps.com. They've been good to me and reliable. :-D.

Digital Ocean

64-bit 12.04 LTS or 14.04 image.

I like to start off by giving my VPS a domain name such as <droplet.coolaj8.com>.

Then I ssh root@droplet.coolaj86.com

After I enter the generated password I immediately create a new user with sudo privileges.

adduser ${USER}
adduser ${user} sudo # or wheel if sudo doesn't exist
exit

Locally I edit my ~/.ssh/config

Host droplet.coolaj86.com
User ${USER}
# Port 2222

Then I log in with the new user and test the sudo access by installing good stuff and editing the sshd_config

SERVER='droplet.coolaj86.com'
ssh-copy-id ${SERVER}
rsync -avhHPz ~/.gitconfig ${SERVER}:~/
rsync -avhHPz ~/.vimrc ${SERVER}:~/
rsync -avhHPz ~/.vim/ ${SERVER}:~/.vim/
rsync -avhHPz ~/.jshintrc ${SERVER}:~/
ssh ${SERVER}

ssh-keygen
cat ~/.ssh/authorized_keys

sudo apt-get update
sudo apt-get install --yes \
  vim \
  fail2ban \
  screen

sudo update-alternatives --config editor

And next I edit sshd_config

sudo vim /etc/ssh/sshd_config

These get changed

#Port 2222
PermitRootLogin no
PasswordAuthentication no

restart ssh

sudo service ssh restart

sudo apt-get install --yes \
  rsync \
  wget \
  curl \
  git \
  htop \
  build-essential

fish

sudo apt-add-repository ppa:fish-shell/release-2
sudo apt-get update
sudo apt-get install fish

sudo chsh -s $(which fish) $(whoami)
exit

And log back in (by hitting up to reveal the previous command and then enter)

ssh ${SERVER}

Node.js

NODEVER=v0.10.29
wget http://nodejs.org/dist/${NODEVER}/node-${NODEVER}-linux-x64.tar.gz
tar xvf node-${NODEVER}-linux-x64.tar.gz
rm node-${NODEVER}-linux-x64/{LICENSE,ChangeLog,README.md}
sudo rsync -avhHP node-${NODEVER}-linux-x64/ /usr/local/

# for vim, etc
npm install -g \
  jshint \

# for quick development
npm install -g \
  yo \
  generator-angular

# for manual tinkering
npm install -g \
  jade \
  less \
  pakmanager \
  uglify-js \
  grunt-cli \
  html2jade

rvm

echo "--no-rdoc --no-ri" >> ~/.gemrc
\curl -L https://get.rvm.io | bash -s stable --ruby
source /home/aj/.rvm/scripts/rvm

# compass for yo
gem install sass

ThrustVPS

Locale

I find that if I don't manually set the locale for my VPSes, it won't be set and then I get a bunch of perl errors.

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8

dpkg-reconfigure locales

Absolute Essentials

I've had at least one case where the repositories had been left empty, so it's always good to check:

cat universe /etc/apt/sources.list
# you should see these two sources listed in the file
#deb http://us.archive.ubuntu.com/ubuntu/ lucid main universe multiverse
#deb http://us.archive.ubuntu.com/ubuntu/ lucid-security main universe multiverse
# you may or may not want to add regular updates in addition to security updates
#deb http://us.archive.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse

sudo apt-get update

sudo apt-get install -y \
  ssh \
  rsync \
  fail2ban \
  vim

user accounts & security

Replace myuser with the name of the user you wish to create.

You will be prompted to enter user profile details. You can just leave everything blank, but I like to put my name.

USER=myuser
adduser ${USER}

After you put in your name you can just leave the rest blank.

adduser ${USER} sudo
exit # leave the VPS and get back to your own system

Now back on your own computer test the account and copy over your favorite user preferences.

Change myuser and myvps.com to your user name and your domain / website name (or your IP address if you haven't managed your DNS yet).

USER=myuser
VPS=myvps.com

rsync -avh ~/.vimrc ${USER}@${VPS}:~/.vimrc
rsync -avh ~/.gitconfig ${USER}@${VPS}:~/.gitconfig

You should never login as root. Now that your user is set up and tested working, root should be disabled right away.

ssh ${USER}@${VPS}

sudo vim /etc/ssh/sshd_config

Look for the line with PermitRootLogin yes and change it to PermitRootLogin no. WARNING: never do this from the root account. Always do it from your user account.

sudo service ssh restart

Change myvps.com to your hostname / domain / website (even if you haven't configured it yet in DNS)

VPS=myvps.com
sudo hostname ${VPS}
sudo bash -c "echo ${VPS} > /etc/hostname"

Now change your default editor to your editor of choice (which should be vim).

update-alternatives --config editor

Bare Bones

sudo apt-get install -y \
  bash-completion \
  command-not-found \
  man-db \
  psmisc \
  tasksel

#  dialog \

sudo tasksel
# Basic Server - 1
# SSH Server - 12

# remove other stuff - apache5, mysql, samba, postfix, sendmail, etc

/etc/skel/.bashrc

if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

basic utils

sudo apt-get install -y \
  htop \
  iftop \
  dnsutils \
  ntpdate \
  curl \
  wget \
  ssh \
  fail2ban \
  vim

sudo ntpdate ntp.ubuntu.com
# note, some VPSes don't allow setting the time

development tools

sudo dd if=/dev/zero of=/128mb.swap bs=1M count=128
sudo mkswap /128mb.swap
sudo swapon /128mb.swap
# node, some VPSes don't allow swap

sudo apt-get install -y \
  git-core \
  build-essential \
  cmake \
  libssl-dev \
  gitosis \
  git-svn

echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local

.bash_profile

# Aliases
alias ll='ls -lah'
alias grep='grep --color=auto'

# For user@host.domain.tld:/path/to/curdir shows user@host:curdir, colorized
export CLICOLOR=1
export PS1="\[\e[1;34m\]\u\[\e[0;37m\]@\[\e[0;32m\]\h\[\e[0;37m\]:\[\e[0;35m\]\W\[\e[0m\] \$ "

nodejs

mkdir ~/Code
cd ~/Code
git clone git://github.com/joyent/node
cd node
git checkout v0.4.12
rm -rf ~/Code/node/*
git checkout v0.4.12 ./
#./configure --prefix=/usr/local
# make -j 4
# make install
make -f Makefile.cmake
cd ~/Code/node/build
sudo make install

cd ~/
curl http://npmjs.org/install.sh | sudo sh

sudo npm install -g \
  validate-json \
  uglify-js \
  ender \
  spark

# TODO package mkjs

git clone git://github.com/coolaj86/connect-vhoster ~/webapps
sudo mv ~/webapps /var/webapps
ln -s /var/webapps ~/webapps
cd ~/webapps
cp config.default.js config.js
mkdir -p vhosts
npm install
# /etc/init/webapps.conf must not be a symlink
sudo cp ~/webapps/webapps.conf /etc/init/webapps.conf

Load webapps into ~/webapps/vhosts/, test that they work, and start the webapps service.

TODO: github hooks


By AJ ONeal

Was this useful to you? Share it!

Also, you can give me a tip or hire me.


Published

2010-10-15

Categories


Tags