Skip to content

Instantly share code, notes, and snippets.

@kwokhou
Forked from jondkinney/README.md
Last active June 20, 2019 06:01
Show Gist options
  • Save kwokhou/57993ccc68a99599a2c0ac0295e5f0fa to your computer and use it in GitHub Desktop.
Save kwokhou/57993ccc68a99599a2c0ac0295e5f0fa to your computer and use it in GitHub Desktop.
Creating deploy user on Linode / Ubuntu

Create deploy user

Log in with ssh root@public-ip

Setup default editor

select-editor

Add a user, disable password & skip questions

adduser --disabled-password --gecos "" deploy

Add the user to the SUDOERS list with usermod (or edit sudoer file with visudo)

usermod -aG sudo deploy

Disable root account and login

Change the default SSH port and disallow root acces. vim /etc/ssh/sshd_config

# What ports, IPs and protocols we listen for
Port 16888

...
PermitRootLogin no

Logout and reboot your linode via linode web interface. Don't attempt to restart SSHD while connected. :)

Test the new settings - Log back in with ssh deploy@your_ip -p 16888 and log out again

Setup password-less sudo

Run visudo and add %deploy ALL=(ALL) NOPASSWD: ALL

Setup password-less ssh

Create your authorized keys file

mkdir ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

Logout and upload your public key

cat ~/.ssh/id_rsa.pub | ssh deploy@public-ip -p 16888 'cat >> .ssh/authorized_keys'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment