Skip to content

Instantly share code, notes, and snippets.

@tjmw
Last active August 29, 2015 14:19
Show Gist options
  • Save tjmw/73d36d0528884e60d4a6 to your computer and use it in GitHub Desktop.
Save tjmw/73d36d0528884e60d4a6 to your computer and use it in GitHub Desktop.
Misc Ubuntu Server Setup

Add new user with home dir

useradd -m USERNAME
passwd USERNAME

Add to sudoers

sudo usermod -a -G sudo USERNAME

Note: need to log out and back in for this to take effect.

Setup SSH keys

For given user:

mkdir .ssh
chmod 0700 .ssh

Add public key to ~/.ssh/authorized_keys

On local machine add to ~/.ssh/config:

Host <name>
  HostName <remote host>
  User USERNAME
  IdentityFile /path/to/private/key

Then ssh in with:

$ ssh <name>

Disable login with password

In /etc/ssh/sshd_config:

PasswordAuthentication no

Reload config with:

$ kill -HUP <sshd pid>

Ubuntu Firewall

$ sudo ufw allow openssh
$ sudo ufw allow 80
$ sudo ufw allow 443
$ sudo ufw enable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment