Homelab

Active Started Jun 18, 2020 10 jots

HOMELAB

Status

Active since June 2020.

Devices

host OS Desktop services
penny CachyOS Hyprland (Wayland) web host, KVM/QEMU hypervisor
lucky Debian GNOME jellyfin, sabnzbd, KVM/QEMU hypervisor
hal Fedora Server N/A (minimal) rsync backups, NFS, Ansible controller, KVM/QEMU hypervisor, Grafana server
walkside OpenWrt N/A (router) DHCP, DNS, Firewall

Jots from this project

Bypassing a locked root account in RHEL10 is different than RHEL7/8/9 because rd.break no longer works; init=/bin/bash must be used. Moreover, even with enforcing=0 included, the system will break unless sudo restorecon -vZ /etc/shadow is also run from the chroot after any passwd edit to root.

Situation: ssh-copy-id succeeds, but password still required to connect:

Triage:

To verify that the fingerprint of the local public key matches to a corresponding fingerprint in the remote ~/.ssh/authorized_keys file, run ssh-keygen -lf ~/.ssh/authorized_keys on the remote device, then ssh-keygen -lf ~/.ssh/id_<YOUR_KEY>.pub on the local device. There should be a match if ssh-copy-id succeeded.

Root Cause

The issue is not the key's content but the…

Abridged Only the first 500 characters are shown here. The rest of this jot is in the ssh drawer →

Situation: Adding a new Arch Linux server to monitoring in a Prometheus/Grafana environment

Run this as sudo on the server to be monitored:

pacman -S prometheus-node-exporter prometheus
ufw allow 9090/tcp 9100/tcp
ufw reload
systemctl enable --now prometheus 
systemctl enable --now prometheus-node-exporter

Then add a new data source in the Grafana web GUI accessed at port :3000 on the Grafana server.

Some partition commands

fdisk -l     #grab info on disks
resize2fs     #resize a filesystem
lvreduce     #resize a logical volume
lvextend     #extend a logical volume

fdisk /dev/<disk>    #partition a disk. 

`g` in fdisk = gpt
`n` in fdisk = label
`t` in fdisk = type (lvm, swap, nfs)
`b` in fdisk = delete
`p` in fdisk = print change buffer without write
`w` in fdisk = write changes

findmnt --verify    #an /etc/fstab-scanning lifesaver

like nobody puts…

Abridged Only the first 500 characters are shown here. The rest of this jot is in the RHEL drawer →

in /etc/autofs/auto.master: /- /etc/autofs/auto.exec --timeout=60

the /- declares that this is a direct mapping, rather than an indirect mapping.

then in /etc/autofs/auto.exec: /srv/share -fstype=nfs,rw,soft pal:/srv/share

this will declare everything necessary this particular autofs mount to work, as long as the nfs share has been set up on the host here named pal

to secure an SSH server:

  • root login disabled
  • key based auth for others
  • fail2ban
  • block IP from some countries at firewall level (China, North Korea, etc)

from here

autofs using auto.master.d

in auto.master.d/pal.autofs: /- /etc/pal.auto --timeout=60

then, in /etc/pal.auto: /srv/share -fstype=nfs,rw,soft pal:/srv/share

ssh unavailable until user login

After rebooting a server, I couldn't SSH in until manually logging in on the device itself... everything changed when nmcli attacked:

sudo nmcli -f NAME,UUID,TYPE,DEVICE connection show   # list connections; grab UUID 
nmcli -g connection.permissions connection show <UUID>     # if `user\:<user>`, restricted
sudo nmcli connection modify <UUID> connection.permissions ""
sudo nmcli connection modify <UUID> connection.autoconnect yes

ssh server hardening

#/etc/ssh/sshd_config.d/10-hardening.conf

PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
PubkeyAuthentication yes
AllowUsers elias ansible

when using /etc/exports.d/ instead of writing the /etc/exports file, the filename does not matter but its extension must be exports e.g.:

# /etc/exports.d/10-share.exports

/srv/share *(rw,no_root_squash)