Git Product home page Git Product logo

secure-server-setup's Introduction

Secure Server Setup

Typically, a cloud server provides a machine with root access and insecure setup. This ansible playbook is designed to fix that. It is based on Ubuntu 20.04 (LTS) or 21.04 image, but it should be applicable to other Ubuntu images.

Set Up Server

Copy inventory file

cp inventory.sample inventory

Update information in the inventory file. Mostly like you will need to update the server IP and hostname fields. Then run main ansible playbook.

ansible-playbook main.yml

The main ansible playbook will both set up the machine and also secure the machine.

Set up machine:

  1. Create Users: Create "ansible" and "ubuntu" users and allow them sudo access. The idea is to have "ansible" to run ansible playbooks automatically and "ubuntu" for ad hoc manual server management. ("ubuntu" is my chosen user. You can configure it in inventory file)
  2. Configure Machine: Set the hostname (based on inventory file) and timezone (Los Angeles Time)
  3. Create aliases for easy server management
  4. Update machine: Simply update and upgrade all applications shipped with the OS.
  5. Install some essential software
  6. Optionally install node exporter (configurable in inventory)
  7. Optionally install promtail (configurable in inventory)

Secure machine:

  1. Install firewall
  2. Install fail2ban
  3. Disable the default ssh port of 22, and set up the alternative port.
  4. Enable firewall to allow the alternative port and deny 22.
  5. Disable root account access
  6. Disable password authentication.

After running the main playbook, you can no longer re-run these two playbooks because you no longer have the root account access. Instead, you need to use "ubuntu" or "ansible" users to access server using ssh key through the alternative port.

Other considerations

You may want to experiment the machine setup without the security lock-down, or vice versa. The repo provides separate playbooks for setup and security

Setup:

ansible-playbook main_setup.yml

Security:

ansible-playbook main_security.yml

That's it!

secure-server-setup's People

Contributors

dylanschultzie avatar husonghua avatar polkachuintern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

secure-server-setup's Issues

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.