Skip to content

ubuntu setup

cowboy edited this page Oct 25, 2014 · 20 revisions

(tested with 14.04.1 LTS)

"root" user tab

Login

ssh root@aaa.bbb.ccc.ddd

Update APT

export DEBIAN_FRONTEND=noninteractive
apt-get -qq -y update && apt-get -qq -y dist-upgrade

Add primary user account and restrict logins to that user only

user=cowboy
adduser $user --gecos '' && adduser $user sudo
sed -i.bak -r 's/^(PermitRootLogin) .*/\1 no/;$a\\nUseDNS no\nAllowUsers '$user /etc/ssh/sshd_config
reload ssh

Don't close this tab

If anything went wrong, this tab is where you'll fix things! Leave this tab open until everything is done, and you've verified that everything works.

"primary" user tab

Login

ssh aaa.bbb.ccc.ddd

Ensure sudo works

sudo date

Install dotfiles

bash -c "$(curl -fsSL https://bit.ly/cowboy-dotfiles)" && source ~/.bashrc

Copy public key and restrict ssh logins to key-only

sudo cp ~root/.ssh/authorized_keys ~/.ssh/ && \
sudo chown $USER:$USER ~/.ssh/authorized_keys && \
sudo sed -i.bak -r 's/#(PasswordAuthentication) yes/\1 no/' /etc/ssh/sshd_config && \
sudo reload ssh

Verify that everything works

Try to ssh into the server in a new tab. If you can login without a password, your SSH public key is where it needs to be and the "root" user tab may be closed safely. If not, ensure that ~/.ssh/authorized_keys exists and has the correct permissions!

Reference

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-14-04

Clone this wiki locally