Skip to content

ubuntu setup

cowboy edited this page Nov 21, 2014 · 20 revisions

For context, see the general dotfiles installation instructions.

(tested with 14.04.1 LTS)

NOTE THAT THESE INSTRUCTIONS HAVE BEEN REPLACED WITH THIS ANSIBLE PLAYBOOK

https://github.com/cowboy/dotfiles/blob/master/ansible/roles/ubuntu.yml

(the default password is "test")

--

--

"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

(you'll need to enter a password)

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

Note: if you're not me, this step will be different. READ THIS BEFORE USING THE FOLLOWING COMMAND!

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