Skip to content

Instantly share code, notes, and snippets.

@safarista
Last active December 16, 2015 09:28
Show Gist options
  • Save safarista/5412995 to your computer and use it in GitHub Desktop.
Save safarista/5412995 to your computer and use it in GitHub Desktop.
Securing SSH on UBUNTU Server 12.04 on a VPS
  1. On the VPS. Setup a user in sudo group with sudo permissions
  • $ adduser deployer --ingroup sudo
  • NOTE: On Ubuntu >= -v11.0 the admin group was removed, the default is sudo
  1. On your local machine, install ssh-copy-id:
  • $ brew install ssh-copy-id
  1. Then, copy your ssh certificate onto your new slice form your local machine: enter password on prompt
  • $ ssh-copy-id deployer@IP_ADDRESS_OF_VPS
  1. After testing that you can ssh into your VPS, open the sshd_config file on your slice, to improve security:
  • $ sudo nano /etc/ssh/sshd_config
  1. The main things to change (or check) are:
  Port 33221          <--- change to a port of your choosing 
  Protocol 2 
  PermitRootLogin no 
  PasswordAuthentication no 
  UseDNS no 
  AllowUsers deployer 
  1. Save your changes and reload your sshd file:
  • $ sudo /etc/init.d/ssh reload

NOTE: Your VPS is now ready but remember your ssh --port when you log in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment