After setting up my Linux servers, there are a few things I do before I use them for their intended purpose. This ranges from security, to tools, to config. Join me as we set up our first Linux server in this tutorial and walk through setting it up proper (and maybe some bonus items sprinkled in).
VIDEO 📺 Watch Video
Update 1
2
3
sudo apt-get update
sudo apt-get upgrade
Reconfigure unattended-upgrades
1
sudo dpkg-reconfigure --priority = low unattended-upgrades
Verify unattended upgrades configuration file in your text editor of choice
1
/etc/apt/apt.conf.d/20auto-upgrades
To disable automatic reboots by the automatic upgrades configuration edit the following file:
1
/etc/apt/apt.conf.d/50unattended-upgrades
and uncomment the following line by removing the leading slashes:
1
//Unattended-Upgrade::Automatic-Reboot "false" ;
Account add user
add to sudoers
1
sudo usermod -aG sudo someuser
SSH Server install
1
sudo apt-get install openssh-server
copy key from client to server
switch to key based auth
1
sudo nano /etc/ssh/sshd_config
Add these attributes
1
2
PasswordAuthentication no
ChallengeResponseAuthentication no
Networking static IP
sudo nano /etc/netplan/01-netcfg.yaml
1
2
3
4
5
6
7
8
9
10
11
network :
version : 2
renderer : networkd
ethernets :
ens18 :
dhcp4 : no
addresses :
- 192.168.0.222/24
gateway4 : 192.168.0.1
nameservers :
addresses : [ 192.168.0.4 ]
Install oh-my-zsh
1
2
3
4
5
sudo apt-get update
sudo apt-get install zsh
sudo apt-get install powerline fonts-powerline
sh -c " $( curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh) "
Fix LVM You should see your logical volumes
1
2
3
lvm> lvscan
ACTIVE '/dev/vgubuntu-server/root' [ <168.54 GiB] inherit
ACTIVE '/dev/vgubuntu-server/swap_1' [ 980.00 MiB] inherit
resize the logical volume group, usually the first one in the list but check to be sure!
1
lvextend -l +100%FREE /dev/vgubuntu-server/root
You should see:
1
2
Size of logical volume vgubuntu-server/root changed from <138.54 GiB ( 35466 extents) to <168.54 GiB ( 43146 extents) .
Logical volume vgubuntu-server/root successfully resized
resize the file system
1
sudo resize2fs /dev/vgubuntu-server/root
Check to see file system size
You should see:
1
2
3
4
5
6
7
Filesystem Size Used Avail Use% Mounted on
tmpfs 1.6G 3.9M 1.6G 1% /run
/dev/mapper/vgubuntu--server-root 166G 89G 70G 56% /
tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda1 511M 4.0K 511M 1% /boot/efi
tmpfs 1.6G 0 1.6G 0% /run/user/1000
You should see:
1
2
3
4
resize2fs 1.46.5 ( 30-Dec-2021)
Filesystem at /dev/vgubuntu-server/root is mounted on /; on-line resizing required
old_desc_blocks = 18, new_desc_blocks = 22
The filesystem on /dev/vgubuntu-server/root is now 44181504 ( 4k) blocks long.
hostname 1
sudo hostnamectl set-hostname
Time Zone Check time zone:
Change time zone:
1
sudo timedatectl set-timezone
You can also use if you want a menu.
1
sudo dpkg-reconfigure tzdata
NTP Time 1
sudo nano /etc/systemd/timesyncd.conf
1
sudo timedatectl set-ntp off
1
sudo timedatectl set-ntp on
install kvm agent 1
sudo apt-get install qemu-guest-agent
firewall 1
sudo ufw default deny incoming
1
sudo ufw default allow outgoing
fail2ban 1
sudo apt-get install fail2ban
1
sudo cp /etc/fail2ban/fail2ban.{ conf,local}
1
sudo cp /etc/fail2ban/jail.{ conf,local}
1
sudo nano /etc/fail2ban/jail.local
check status
1
sudo fail2ban-client status
1
sudo fail2ban-client status sshd
Links ⚙️ See all the hardware I recommend at https://l.technotim.live/gear
🚀 Don’t forget to check out the 🚀Launchpad repo with all of the quick start source files