All Projects → TedLeRoy → first-ten-seconds-redhat-ubuntu

TedLeRoy / first-ten-seconds-redhat-ubuntu

Licence: GPL-3.0 license
A bash script to help secure a new CentOS or Ubuntu server quickly and easily.

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to first-ten-seconds-redhat-ubuntu

Ansible Role Firewall
Ansible Role - iptables Firewall configuration.
Stars: ✭ 343 (+1917.65%)
Mutual labels:  firewall, centos
Setup Nginx Webserver
🚀Setup a perfect webserver on CentOS/Redhat 7.x guide with understanding.
Stars: ✭ 65 (+282.35%)
Mutual labels:  firewall, centos
Bluewall
Bluewall is a firewall framework designed for offensive and defensive cyber professionals.
Stars: ✭ 92 (+441.18%)
Mutual labels:  firewall, centos
awesome-script
常用的 shell 脚本,包括 centos, Ubuntu, Mac osx, 以及 Docker, Python 等常用软件的安装, 配置, 开发环境搭建的脚本.
Stars: ✭ 50 (+194.12%)
Mutual labels:  centos
RapidCopy
RapidCopy is portable version of FastCopy that runs GNU/Linux with Qt5.
Stars: ✭ 44 (+158.82%)
Mutual labels:  centos
ddos-mitigation
Tips to mitigate and secure your large-scale server against DDoS attacks.
Stars: ✭ 58 (+241.18%)
Mutual labels:  firewall
Learning Linux
Linux 学习笔记,基于《鸟哥的 Linux 私房菜 第四版(CentOS7)》以及各种的网络资源
Stars: ✭ 16 (-5.88%)
Mutual labels:  centos
DirectFire Converter
DirectFire Firewall Converter - Network Security, Next-Generation Firewall Configuration Conversion, Firewall Syntax Translation and Firewall Migration Tool - supports Cisco ASA, Fortinet FortiGate (FortiOS), Juniper SRX (JunOS), SSG / Netscreen (ScreenOS) and WatchGuard (support for further devices in development). Similar to FortiConverter, Sm…
Stars: ✭ 34 (+100%)
Mutual labels:  firewall
butterfly
Butterfly connects Virtual Machines and control their traffic flow
Stars: ✭ 48 (+182.35%)
Mutual labels:  firewall
kubevirt-tutorial
Demo that guides users through an end to end KubeVirt experience.
Stars: ✭ 29 (+70.59%)
Mutual labels:  centos
aws-network-firewall-deployment-automations-for-aws-transit-gateway
AWS Network Firewall Deployment Automations for AWS Transit Gateway configures the AWS resources needed to filter network traffic. This solution saves you time by automating the process of provisioning a centralized AWS Network Firewall to inspect traffic between your Amazon VPCs.
Stars: ✭ 20 (+17.65%)
Mutual labels:  firewall
first-steps-and-hardening-in-ubuntu-server-and-docker
First Steps in Ubuntu (Server) / Hardening and Config With Docker
Stars: ✭ 28 (+64.71%)
Mutual labels:  ubuntu-server
opnsense-starterkit
Try opnsense, build opnsense images or start development
Stars: ✭ 18 (+5.88%)
Mutual labels:  firewall
dots
digital ocean api typescript/javascript wrapper
Stars: ✭ 65 (+282.35%)
Mutual labels:  firewall
openconnect-installer
Automatically set up an Openconnect/Anyconnect VPN server(ocserv) with Let's Encrypt with just one command in CentOS 8.
Stars: ✭ 64 (+276.47%)
Mutual labels:  centos
pg dba scripts
PostgreSQL DBA scripts
Stars: ✭ 30 (+76.47%)
Mutual labels:  centos
rackshift
RackShift 是开源的裸金属服务器管理平台,功能覆盖裸金属服务器的发现、带外管理、RAID 配置、固件更新、操作系统安装等。
Stars: ✭ 467 (+2647.06%)
Mutual labels:  centos
login-shell
SSH登陆显示脚本
Stars: ✭ 166 (+876.47%)
Mutual labels:  centos
Silverdog
An audio firewall for Chrome!
Stars: ✭ 65 (+282.35%)
Mutual labels:  firewall
ssa
Web panel for small Debian and Ubuntu servers.
Stars: ✭ 16 (-5.88%)
Mutual labels:  ubuntu-server

First-ten-post-run

first-ten-seconds-redhat-ubuntu

A bash script to help perform initial security hardening steps on a new Rocky Linux 8, Alma Linux 8, Red Hat 8, or Ubuntu 20.04 server quickly and easily.

Background

Note: I changed the name of this project from first-ten-seconds-centos-ubuntu to first-ten-seconds-redhat-ubuntu to account for the fundamental changes made by Red Hat and the CentOS project, making it CentOS unsuitable for many uses. I'm shifting to CentOS alternatives like Rocky Linux and Alma Linux.

This doesn't "lock down" your server completely, but improves the security posture of a new Red Hat 8, Rocky Linux 8, Alma Linux 8 or Ubuntu 20.04 server so you can take more time with further improvements if you need to.

Inspired by Jerry Gamblin's blog post: https://jerrygamblin.com/2016/07/13/my-first-10-seconds-on-a-server/ as well as Bryan Kennedy's post: https://plusbryan.com/my-first-5-minutes-on-a-server-or-essential-security-for-linux-servers, and DigitalOcean guides, Red Hat, and Ubuntu security best practices, and things I like to do myself for new servers.

The script will determine if it's being run on a Rocky Linux, Alma Linux, Red Hat, or Ubuntu server and will run commands appropriate for the OS.

It is strongly recommended to only run this on clean installs after a non-root user with sudo permission has been set up and key based ssh authentication is configured and tested for that user.

The following tutorials can help you set up key based authentication:

My YouTube series, part 1 through 7 for key based authentication on Ubuntu: https://www.youtube.com/watch?v=ugpAr5fhA1s&t=16s

Digital Ocean CentOS 8 Key Based Authentication tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-on-centos-8

Digital Ocean Ubuntu 20.04 Key Based Authentication tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-on-ubuntu-20-04

This script is being created in support of my Linux Security course to give students a jump on securing newly built CentOS and Ubuntu servers.

Project Goals

This project seeks to roll a few common security best practices for new servers into a script that will determine whether it's being run on CentOS or Ubuntu and will run the security related commands appropriate for the OS it's being run on.

What It Does

This script will do the following for Ubuntu:

  1. Ensure a non-root user is set up.

  2. Ensure non-root user also has sudo permission (script won't continue without it).

  3. Ensure SSH is allowed through the ufw firewall.

  4. Ensure ufw firewall is enabled.

  5. Lock down SSH if you choose y for that step.

    1. Set SSH not to display banner
    2. Disable all forwarding
    3. Disable root login over SSH
    4. Ignore rhosts
    5. Disable password authentication
  6. Install fail2ban and configured it to protect SSH. (note) For a default Ubuntu server installation, automatic security updates are enabled so no action was taken regarding updates.

The script will do the following for Red Hat and Red Hat based distro's:

  1. Ensure a non-root user is set up.

  2. Ensure non-root user also has sudo permission (script won't continue without it).

  3. Ensure SSH is allowed through the firewalld firewall.

  4. Ensure firewalld firewall is enabled.

  5. Locked down SSH if you choose y for that step.

    1. Set SSH not to display banner
    2. Disable all forwarding
    3. Disable root login over SSH
    4. Ignore rhosts
    5. Disable password authentication
  6. Install fail2ban and configured it to protect SSH.

  7. Ensure automatic security updates are configured.

Prerequisites

You must have sudo permissions to run the commands inside the script.

The script should not be run as root, but the user running it will be prompted for sudo credentials once it runs. sudo password should be entered to continue.

Warning

Be sure you have read and understand what this file does before running it.

You can read the man page for each command and option to see what it does.

Any time the creator of a script says it has to be run with sudo permissions or as root, understand why and use caution.

This script has to be run by a user with sudo permissions because the system update, firewall, and ssh related commands it uses must be run as root. It should be run by a non-root user but sudo credentials should be provided when prompted.

Usage

The latest version of this script can be run with the following single line at the Linux terminal on any Rocky Linux 8, Alma Linux 8, Red Hat 8, or Ubuntu 20.04 new installation after a non-root user with sudo privileges has been set up and key based authentication for that user using SSH configured:

bash <(curl -s https://raw.githubusercontent.com/TedLeRoy/first-ten-seconds-redhat-ubuntu/master/first-ten.sh)

Alternatively, you can clone the full repository locally or just copy and run the first-ten.sh script from the link below.

https://raw.githubusercontent.com/TedLeRoy/first-ten-seconds-redhat-ubuntu/master/first-ten.sh

You could use the following commands (you may have to install wget first if you did a minimal install):

wget https://raw.githubusercontent.com/TedLeRoy/first-ten-seconds-redhat-ubuntu/master/first-ten.sh
chmod +x first-ten.sh
./first-ten.sh

You can also follow the traditional method for GitHub projects and create your own clone then run from that.

git clone https://github.com/TedLeRoy/first-ten-seconds-redhat-ubuntu.git
cd first-ten-seconds-redhat-ubuntu
./first-ten.sh

Issues, Feature Requests, Input

Please report issues, request features, or provide your input or feedback about the script here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].