Code Monkey home page Code Monkey logo

lockdown.sh's Introduction

lockdown.sh



Lockdown.sh is a single file zero config shell script to be run to lockdown a newly installed linux os. Lockdown.sh aims to set a sensible baseline which can be built upon for specific needs.

  • Zero Config
  • Zero Install
  • Single file shell script

WARNING

This script changes the ssh port to 141. And restricts ssh to key only for the created admin user if an admin user is created.

Usage

Download and run the script as root, select which sections to run when prompted.

wget https://raw.githubusercontent.com/x08d/lockdown.sh/master/lockdown.sh
chmod +x ./lockdown.sh
./lockdown.sh

What does it do?

  • Updates packages
  • Restricts firewall to only allow ssh on 141
  • Installs fail2ban
  • Configures the kernel
  • Adds daily cronjob to update packages on server
  • Installs and configures auditd with sensible rules
  • Disables core dumps
  • Restricts logins
  • Create a new admin user
  • Restricts ssh and enables only the created admin user
  • Adds a legal banner to /etc/issue and /etc/issue.net
  • Installs packages recommended by lynis
  • Installs and sets up aide
  • Enables process accounting
  • Disables uncommon filesystems
  • Disables firewire and usb storage
  • Disables uncommon network protocols
  • Restricts access to /root
  • Restrict access to compilers
  • Moves tmp to tmpfs
  • Remounts /tmp /proc /dev /run to be more restrictive
  • Purges old and removed packages

Supported OS

  • Debian 10
  • Debian 8
  • (Should work with most debian and debian based OS's)
  • Others are coming soon

Contributing

Please open pull requests and issues on github for anything you find.

References

lockdown.sh's People

Contributors

dolegi avatar rcobelli avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lockdown.sh's Issues

Ubuntu Server x64 20.04 focal - apt-listbugs not available

Hello,

I just installed a new Ubuntu Server instance, and after doing basic update I thought I would use this lockdown script. However, I noticed that this is happening during the AIDE installation.

OS: Ubuntu 20.04 focal
Kernel: x86_64 Linux 5.4.0-33-generic

running sudo ./lockdown.sh

{
apt install apt-listbugs apt-listchanges needrestart debsecan debsums libpam-cracklib aide usbguard acct -y
}
Install recommended packages
Run the above commands? [y/N]
y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package apt-listbugs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'apt-listbugs' has no installation candidate
{
aideinit;
mv /var/lib/aide/aide.db.new /var/lib/aide/aide.db
}
Setup aide

Needless repetition ..

If you're expecting unattended-upgrades to provide (security) upgrades, automatically then this section of code is pointless:

# Add Daily Update Cron Job
touch job
echo "@daily apt update; apt dist-upgrade -y" >> job
crontab job
rm job
  • Note: The more idiomatic approach would be writing to /etc/cron.daily/apt-upgrade, or similar. Not using cron.

However I note that you never actually install unattended-upgrades, only attempt to reconfigure it. That's probably a mistake.

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.