Skip to content

Instantly share code, notes, and snippets.

@ryanwi
Last active May 22, 2022 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanwi/fe17ed9734ec8b074cac5d40e5919299 to your computer and use it in GitHub Desktop.
Save ryanwi/fe17ed9734ec8b074cac5d40e5919299 to your computer and use it in GitHub Desktop.
Setting up a new linux web server

create limited user

adduser example_user

adduser example_user sudo OR usermod -aG sudo example_user

login as limited user

set up ssh for limited user

mkdir ~/.ssh chmod 700 ~/.ssh vim ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys

Harden SSH Access

  • disable password authentication
  • disable root login over ssh

sudo vim /etc/ssh/sshd_config PasswordAuthentication no PermitRootLogin no

sudo systemctl reload sshd sudo service sshd restart

Configure a Firewall

sudo ufw app list sudo ufw allow OpenSSH sudo ufw enable sudo ufw status

install nginx

sudo apt-get update && sudo apt-get upgrade sudo apt-get install nginx

configure firewall for Nginx

sudo ufw allow 'Nginx HTTP' sudo ufw allow 'Nginx HTTPS'

Remove Unused Network-Facing Services

https://www.linode.com/docs/guides/remove-unused-network-facing-services

manage nginx process

sudo systemctl stop nginx

Create and configure site

mkdir /var/www/sitename/html cp /etc/nginx/ /etc/nginx/sites-available/sitename vim /etc/nginx/sites-available/sitename ln /etc/nginx/sites-enabled/sitename /etc/nginx/sites-available/sitename

Enable SSL

Monitoring

Analtyics

Setup References

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04 https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-22-04

https://www.linode.com/docs/websites/hosting-a-website https://www.linode.com/docs/guides/how-to-install-and-use-nginx-on-ubuntu-20-04/

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04

Security References

https://www.linode.com/docs/security/securing-your-server

https://www.linode.com/docs/guides/security/ https://www.linode.com/docs/guides/using-fail2ban-to-secure-your-server-a-tutorial/

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