PiSignage Player Hardening and Security Best Practices
Optional steps to harden a Raspberry Pi player and keep it reliable in production.
These steps are optional. They strengthen the security of a PiSignage Raspberry Pi player, reduce exposure to risk and keep the player reliable. Run all commands in the Pi terminal. See Issue shell commands or connect to pi terminal.
Some steps change how you reach the player over SSH (port 2022 and
AllowUsers pi). Check that you can still log in from a second session before you close your current one.
Download and install Lynis
Download and extract Lynis 3.1.6, then run an audit of the system.
wget https://downloads.cisofy.com/lynis/lynis-3.1.6.tar.gz
sudo tar -xzvf lynis-3.1.6.tar.gz
cd lynis/
sudo ./lynis audit system
Update system and packages
Update the package database, upgrade installed packages, install unattended-upgrades and enable daily package list updates and unattended upgrades.
# Update package database and system
sudo apt update && sudo apt upgrade -y
# Enable automatic security updates
sudo apt install unattended-upgrades
# Enable unattended upgrades and daily package list updates
sudo sh -c 'echo "APT::Periodic::Update-Package-Lists \"1\";" > /etc/apt/apt.conf.d/20auto-upgrades'
sudo sh -c 'echo "APT::Periodic::Unattended-Upgrade \"1\";" >> /etc/apt/apt.conf.d/20auto-upgrades'
sudo systemctl enable --now unattended-upgrades
# Configure automatic updates
sudo vi /etc/apt/apt.conf.d/50unattended-upgrades
Add these lines to the file. They disable automatic reboot, set the reboot time (used only if reboot is enabled) and remove unused dependencies.
Unattended-Upgrade::Automatic-Reboot "false";
Unattended-Upgrade::Automatic-Reboot-Time "02:00";
Unattended-Upgrade::Remove-Unused-Dependencies "true";
Disable unused accounts
List all accounts, then disable the shell and lock the password of unused system accounts.
# List all accounts
cat /etc/passwd
# Disable unused system accounts
sudo usermod -s /bin/false games
sudo usermod -s /bin/false news
sudo usermod -s /bin/false uucp
# Lock unused accounts
sudo passwd -l games
sudo passwd -l news
Service hardening and optimization
Disable and stop background services you do not need. Errors are ignored for services that are not installed. Only disable dphys-swapfile if you use ZRAM or no swap file.
# Disable unneeded background services
sudo systemctl disable bluetooth
sudo systemctl disable avahi-daemon
sudo systemctl disable triggerhappy
sudo systemctl disable dphys-swapfile # Only if using ZRAM or no swap file
sudo systemctl stop bluetooth
sudo systemctl stop avahi-daemon
# Disable additional non-essential services (ignore errors if not installed)
sudo systemctl disable avahi-daemon.service 2>/dev/null || true
sudo systemctl disable bluetooth.service 2>/dev/null || true
sudo systemctl disable cups.service 2>/dev/null || true
sudo systemctl disable cups-browsed.service 2>/dev/null || true
sudo systemctl disable packagekit.service 2>/dev/null || true
sudo systemctl disable udisks2.service 2>/dev/null || true
sudo systemctl disable upower.service 2>/dev/null || true
Then reload systemd:
sudo systemctl daemon-reload
sudo systemctl reset-fa
The original article lists
reset-faas written above. It looks like a shortenedreset-failed, so check before you run it.
Disable core dumps
Set the hard and soft core dump limits to 0.
sudo tee -a /etc/security/limits.conf > /dev/null << 'EOF'
* hard core 0
* soft core 0
EOF
Secure SSH access
Modify /etc/ssh/sshd_config and add or update these parameters:
Port 2022
PermitRootLogin no
AllowUsers pi
AllowTcpForwarding no
GatewayPorts no
PermitTunnel no
ClientAliveCountMax 2
Compression no
X11Forwarding no
MaxAuthTries 3
MaxSessions 2
TCPKeepAlive no
AllowAgentForwarding no
LogLevel VERBOSE
What this gives you:
- Moving SSH to port 2022 and disabling root login reduces brute-force attempts.
- Access is limited to the user
pi, with limited authentication attempts and sessions. - Disabling forwarding, tunneling, X11 and agent forwarding stops the player from being misused as a relay or proxy.
- Verbose logging improves auditing.
Apply the change by restarting SSH:
sudo systemctl restart ssh
Kernel hardening
Create the file /etc/sysctl.d/99-player2-kernel-hardening.conf and add or verify these parameters:
# TTY Security
dev.tty.ldisc_autoload = 0
# File System Protection
fs.protected_fifos = 2
kernel.core_uses_pid = 1
# Kernel Security
kernel.dmesg_restrict = 1
kernel.kptr_restrict = 2
kernel.sysrq = 0
kernel.unprivileged_bpf_disabled = 1
kernel.randomize_va_space = 2
# IPv4 Network Security
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.tcp_syncookies = 1
# IPv6 Network Security
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
# BPF Hardening
net.core.bpf_jit_harden = 2
Apply it:
sudo sysctl --system
Disable uncommon and unused network protocols
Block dccp, sctp, rds and tipc, unload them if active, and reboot to apply permanently.
# Disable uncommon and unused network protocols
sudo tee /etc/modprobe.d/blacklist-uncommon-protocols.conf > /dev/null << 'EOF'
blacklist dccp
install dccp /bin/false
blacklist sctp
install sctp /bin/false
blacklist rds
install rds /bin/false
blacklist tipc
install tipc /bin/false
EOF
# Unload modules if currently active
sudo modprobe -r dccp sctp rds tipc 2>/dev/null || true
echo "Protocols disabled. Reboot to apply permanently."
Package cleanup and purging
Clean obsolete and unused packages, purge configuration, clear the cache and check for residual (removed but not purged) packages. Firefox is used here as an example of an unnecessary package.
# Clean up unused and obsolete packages
sudo apt autoclean
# Remove unused dependencies and purge configurations
sudo apt autoremove --purge -y
# Clear the local package cache
sudo apt clean
# Final check and additional cleanup
sudo apt autoremove -y
# Identify any residual (removed but not purged) packages
dpkg -l | awk '/^rc/'
# Example: remove unnecessary package
sudo apt remove firefox
# Re-check for residual configuration files
dpkg -l | awk '/^rc/'
Add a legal login banner
Add the same warning banner to /etc/issue and /etc/issue.net. It says the system is for authorized users only, unauthorized access is prohibited and may be prosecuted, and all activity may be logged and monitored.
sudo tee /etc/issue > /dev/null << 'EOF'
*************************************************************
WARNING: This system is for the use of authorized users only.
Unauthorized access is strictly prohibited and subject to
prosecution under applicable laws. All activity may be logged
and monitored.
*************************************************************
EOF
sudo tee /etc/issue.net > /dev/null << 'EOF'
*************************************************************
WARNING: This system is for the use of authorized users only.
Unauthorized access is strictly prohibited and subject to
prosecution under applicable laws. All activity may be logged
and monitored.
*************************************************************
EOF
Secure critical configuration file permissions
Check the current permissions, restrict crontab and sshd_config to mode 600, restrict the cron directories to mode 700 (root only) and verify.
# Verify current permissions
sudo ls -tlr /etc/crontab
# Restrict access to crontab and SSH configuration files
sudo chmod 600 /etc/crontab
sudo chmod 600 /etc/ssh/sshd_config
# Secure cron directories to allow only root access
sudo chmod 700 /etc/cron.d
sudo chmod 700 /etc/cron.daily/
sudo chmod 700 /etc/cron.hourly/
sudo chmod 700 /etc/cron.weekly/
sudo chmod 700 /etc/cron.monthly/
# Verify permissions
sudo ls -ltrd /etc/cron.* /etc/cron.d
Install and enable additional security tools
These tools improve monitoring, auditing and threat detection.
1. sysstat
Provides sar and iostat for activity and performance monitoring. Once enabled it collects CPU, memory and disk metrics continuously.
sudo apt install sysstat -y
sudo sed -i 's/ENABLED="false"/ENABLED="true"/' /etc/default/sysstat
sudo systemctl enable --now sysstat
2. apt-show-versions
Lists installed package versions and available updates. Useful for maintenance and checking updates.
sudo apt install apt-show-versions -y
3. auditd
Logs security related activity such as logins, file modifications and privilege changes. It is the core Linux auditing component for compliance and intrusion detection.
sudo apt install auditd audispd-plugins -y
sudo systemctl enable --now auditd
4. rkhunter
Rootkit Hunter detects rootkits, hidden files and potential backdoors. The --propupd option initializes its database for later integrity checks.
sudo apt install rkhunter -y
sudo rkhunter --propupd
Install and configure the PAM password-strength module
Step 1: Install the PAM password quality module
sudo apt install libpam-pwquality
Step 2: Apply system-wide defaults
Open the file:
sudo nano /etc/security/pwquality.conf
Add or update these lines:
minlen = 12
difok = 3
ucredit = -1
lcredit = -1
dcredit = -1
ocredit = -1
retry = 3
This sets a minimum length of 12, at least 3 characters different from the old password, one uppercase, one lowercase, one digit and one special character, and up to 3 attempts.
Step 3: Change to a stronger password
Log in at pisignage.com, go to Settings and find the Password section. Adjust the password rules to your organization's requirements and update your password. See Settings for the passwords used to access your players, and Default player passwords and how to change them.
Verification
After completing the hardening steps, run Lynis again to confirm your score and that the suggestions are resolved.
sudo ./lynis audit system