My Brother Alex
Howdy Everyone! Today I am going to walk you through setting up a baseline, production ready, Linux machine. I am going to make the assumption that you know how to create and use ssh-keys, you already have the linux box provisioned, and that it has a public facing IPv4 address. You’ll also notice that I won’t guide you through setting up uncomplicated firewall. Since that is very workload dependant, I cannot offer a baseline configuration besides the defaults. I also don’t cover NewRelic in detail. It will get its very own post.
The very first thing you will want to do within any installation; is an immediate update and upgrade of the local packages using your package manager.
sudo apt update -y && sudo apt upgrade -y
Once you have all the latest packages and security updates installed, go ahead and run the interactive configuration tool for unattended-upgrades. I’ve come across both “Yes” and “No” as a default. So I am of the opinion it is best practice to trust but verify. The purpose of this is to automatically install the latest stable security patches.
sudo dpkg-reconfigure unattended-upgrades
Now go ahead and set the timezone on your machine. This might seem silly but its important. Logs will be written with the timestamp from timedatectl. Using your local timezone will ensure your logging is more friendly for human consumption during times of troubleshooting.
timedatectl
sudo timedatectl set-timezone America/Denver
timedatectl
Now you should tell hostnamectl the machines canonical name. Sometimes referred to as a subject alternative name.
hostnamectl
sudo hostnamectl set-hostname host.domain.tld
hostnamectl
After configuring hostnamectl, you’ll want to append your desired hostname to a few values in the /etc/hosts
file. Failure to do so can result in SSL/TLS errors depending on your workload and technology stack. Here is an example below.
127.0.0.1 localhost
127.0.1.1 localhost host.domain.tld domain.tld
4.6.8.12 host.domain.tld domain.tld
Now you’ll want to create a limited sudo user account. This will be the account you will login via ssh with moving forward after the first reboot.
sudo useradd -m -G sudo -s /bin/bash mynewuseraccount
I’ll break down the command. -m
creates the user home directory. -G sudo
adds the user to the sudo group. -s /bin/bash
sets the new users default shell to /bin/bash. The new default shell is zsh. I don’t find it SysAdmin friendly. Once you have the user created. Go ahead and run sudo passwd mynewuseraccount
to configure a password.
To properly secure SSH access, you’ll need to make adjustments to the configuration file for the ssh daemon. You can find it located in /etc/ssh/sshd_config
.
The following lines should be present in your config file. If not, you can simply append these at the bottom of the file.
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no
PermitEmptyPasswords no
Now lets install and enable both Fail2Ban and the Crowdsec Security Engine. Once this is completed, please consider installing any applicable Crowdsec Bouncers and Collections to further protect your machine and underlying applications from cyber attacks.
curl -s https://install.crowdsec.net | sudo sh
sudo apt install fail2ban crowdsec -y
sudo cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
sudo systemctl status fail2ban.service
sudo systemctl start fail2ban.service
sudo systemctl status fail2ban.service
Now its important to get a baseline for logging, monitoring, and alerting. We will want all three in place for a production system. There are two big Observability platforms. NewRelic and DataDog. The NewRelic free plans allows for 100GB/Month of data ingest with no host limit. DataDog free plan allows for 5 monitored hosts with no limit on data ingest. I have chosen to use NewRelic. Going into this section its also important to layout alerts should be actionable. You never want an alert that can be ignored. That will lead to alert fatigue and is an important human aspect to manage.
The NewRelic agent ingests our system logs and system data. This allows us to visualize log types and trends in total logging. This is a great method for spotting changes in the system over time. It also allows us to generate webhook, pagerduty, and other types of alerts based on pre-defined “Golden Metrics” or fully custom NRQL queries.
Consider implementing a custom motd file such as this one below. This is to make the systems easily identifiable when connecting to them remotely.
##################################################
WARNING: This is a company computer system with access restricted to
those with proper authorization. Any unauthorized access attempt
will be investigated and prosecuted to the full extent of the law.
If you are not an authorized user, disconnect now.
<System Role> - <Hardware/VM Type>
##################################################
Remebering Alondra and Aaliyah
Matt’s Guide to CB Radios and more.
De-Google-Fi, Step 1
Matt’s Guide to Securing a Linux Box for Production.
Quick overview of my websites architecture.
One Night in Glacier NP - 2024
Exploring and capturing the scenery in American Truck Simulator, Nebraska DLC
how-to be safe while downloading linux isos.
Exploring South Dakota with the Jacksons.
how I reduced my home page 610 percent.
how-to add oneko.js to the minimal-mistakes jekyll template.
My personal running notes for growing cannabis.
Dealing with CIFS errors between TrueNAS and Debian.
how-to bounce a Juniper JunOS switchport.
how-to fix ‘the list of sources could not be read.’ when using apt.
how-to troubleshoot a home network, by a Network Engineer.
Moving my webserver from OpenLiteSpeed to Caddy
how-to resolve, could not resolve packages.adoptium.net
how-to validate XZ-Utils impact.
How and Why I use Ninite
Manually renewing Certbot on OpenLiteSpeed
Yet Another Benchmark Results
Linux Basics and Core Concepts by Matt F.
how-to Buy and Manage a Web Domain
My Udemy Course Completion Certification.
Scion FRS Service Manual Download and Sources
My Discord Server Widget
How I moved from QUIC.Cloud to BunnyNet CDN.
My High Uptime Plan for 2024.
Personal notes for Magic the Gathering
HTML Hobbiest Webring Landing Page/Post
Method of Procedure for migrating from WordPress to plain HTML.
W900 Tuning Pack DLC Review.
Google Domains is Ending.
Deep dive into OpenLiteSpeed webserver.
how-to resolve my Jekyll/Cloudflare Pages deployment error.
In High School I had one dream that stands out. Own a Porsche by the time I was 26. Looking back, I have no idea where this dream came from; because I was ra...
Personal ramblings about my new town.
Knowledge Filled PDF Bundle
how-to Jellyfun.
ProtonMail Review - 1 Year
how-to manage Pi-Hole.
My new Gaming PC. Its boring but it’ll do.
how-to setup Pi-Hole and Wireguard on Linode.
how-to update the hostname of a Raspberry Pi.
Can a Raspberry Pi Zero host a family VPN Server? Yes.
Logitech G413 Keyboard review.
Razer Huntsman Mini review.
YouTube video cruising through Colorado!
Ramblings about PiAware after one month of operation.
Guide to setup a Raspberry Pi from start to finish!
Guide to configuring the Timezone on a Raspberry Pi.