Skip to content

Instantly share code, notes, and snippets.

@okuryu
Created April 18, 2012 14:05
Show Gist options
  • Save okuryu/2413819 to your computer and use it in GitHub Desktop.
Save okuryu/2413819 to your computer and use it in GitHub Desktop.
Setup Ubuntu

Setup Ubuntu

Setting SSH key

Create the pair of your key on your local machine.

$ mkdir -m 700 ~/.ssh
$ ssh-keygen
$ chmod 600 ~/.ssh/id_rsa ~/.ssh/id_rsa.pub
$ cat ~/.ssh/id_rsa.pub

Setting your public key on your remote machine.

$ mkdir -m 700 ~/.ssh
$ echo "<your public key>" ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys

Start other terminal on local machine and test public key based authorization.

$ ssh <remote hostname>

Setting SSH Server

Edit /etc/ssh/sshd_config.

$ sudo vi /etc/ssh/sshd_config

Off to login by root user.

PermitRootLogin no

Off to login based input password.

PasswordAuthentication no

Check configuration.

$ sudo sshd -t

Restart sshd.

$ sudo service ssh restart

Setting Firewall

Check ufw status.

$ sudo ufw status
Status: inactive

Switch deny for all ports.

$ sudo ufw default deny

Open the only port for SSH.

$ sudo ufw allow 22

Switch ufw to enable.

$ sudo ufw enable

Check ufw status.

$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
22                         ALLOW       Anywhere (v6)

Update packages

$ sudo apt-get update
$ sudo apt-get upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment