Git Product home page Git Product logo

harden's Introduction

Copyright © 2014-2020, Brendan Doms Licensed under the MIT license

Harden

This is a script to prepare an Ubuntu box intended to be used as a public web server. Specifically, it:

  • Creates an admin group user for remote access
  • Disables logging in as root or with a password
  • Sets up a firewall to block most ports

Quick Use

The script is designed to be used out of the box on a modern Ubuntu distro (12.04 and up). You should have wget and some version of python by default, so there's nothing to install. Simply make sure you have root privileges and then run:

wget https://raw.githubusercontent.com/bdoms/harden/master/harden.py
python3 harden.py

Once it finishes, log out (if that didn't happen automatically). You should no longer be able to ssh as root, but your new user should work fine.

Options

Skip User Creation

If you already have a user setup for remote access you can skip that step with the --skip_user option.

Define Ports

You can define which ports will be opened in the -p or --ports list (default: 22 80 443).

To rate limit access to an opened port include it in the --limit_ports list (default: 22).

To log access to an opened port include it in the --log_ports list (default: 22).

Harden uses UFW as its firewall. You can continue to change its behavior after this script has run using its usual commands.

Support HTTP3

By default only TCP is allowed on open ports.

Include the --http3 option for UDP to also be allowed on both ports 80 and 443, as this is required for HTTP3 to work.

No other ports will be affected.

Other Considerations

The basic modern Ubuntu server image used does not include the following packages, but if they are installed they should be removed:

  • vsftp
  • telnetd
  • rsh-server

This is just a list of commonly installed packages in many distributions and is obviously incomplete. Any package that opens a port or allows for remote login should be suspect.

You can use ufw status to check the status of the firewall and something like netstat -ltunp to confirm which ports are active for yourself.

harden's People

Contributors

bdoms avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.