<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dilettant</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dilettant"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Dilettant"/>
	<updated>2026-05-09T19:42:11Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Securing_Alpine_Linux&amp;diff=31526</id>
		<title>Securing Alpine Linux</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Securing_Alpine_Linux&amp;diff=31526"/>
		<updated>2025-11-24T18:44:00Z</updated>

		<summary type="html">&lt;p&gt;Dilettant: added shadow to the required packages as the lock script uses *chage* which is in the shadow package and not installed in alpine by default&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Securing Alpine Linux using Security Technical Implementation Guides (STIGs) involves several steps. STIGs are a series of security requirements and configurations that help to secure systems. While there might not be a specific STIG for Alpine Linux, you can follow general Linux hardening guidelines and apply the principles from other Linux STIGs. Here’s a step-by-step process:&lt;br /&gt;
&lt;br /&gt;
== Update and upgrade system ==&lt;br /&gt;
&lt;br /&gt;
1. Update package lists: {{cmd|doas apk update}}&lt;br /&gt;
&lt;br /&gt;
2. Upgrade installed packages: {{cmd|doas apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
== Install necessary security tools ==&lt;br /&gt;
&lt;br /&gt;
1. Install the {{pkg|audit|arch=}} package: {{cmd|doas apk add audit}}&lt;br /&gt;
&lt;br /&gt;
2. Install other necessary security packages: {{cmd|doas apk add doas shadow logrotate bash-completion openssh-server}}&lt;br /&gt;
&lt;br /&gt;
== User and access management ==&lt;br /&gt;
&lt;br /&gt;
1. Disable root login over SSH: &lt;br /&gt;
Edit {{path|/etc/ssh/sshd_config}} and Set the following parameter as follows {{Cat|/etc/ssh/sshd_config|...&lt;br /&gt;
PermitRootLogin no}}&lt;br /&gt;
&lt;br /&gt;
2. Ensure password complexity:&lt;br /&gt;
Edit {{path|/etc/security/pwquality.conf}} and add or update the following lines:{{Cat|/etc/security/pwquality.conf|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
minlen = 14&lt;br /&gt;
dcredit = -1&lt;br /&gt;
ucredit = -1&lt;br /&gt;
ocredit = -1&lt;br /&gt;
lcredit = -1&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
3. Lock unused system accounts by running the following script:&lt;br /&gt;
   for user in `awk -F: &#039;($3 &amp;lt; 1000) {print $1}&#039; /etc/passwd`; do&lt;br /&gt;
       if [ $user !{{=}} &amp;quot;root&amp;quot; ]; then&lt;br /&gt;
           doas passwd -l $user&lt;br /&gt;
           doas chage -E 0 $user&lt;br /&gt;
       fi&lt;br /&gt;
   done&lt;br /&gt;
&lt;br /&gt;
== File system and directory permissions ==&lt;br /&gt;
&lt;br /&gt;
1. Set appropriate permissions on important directories: {{Cmd|doas chmod 700 /root&lt;br /&gt;
doas chmod 600 /boot/grub/grub.cfg&lt;br /&gt;
doas chmod 600 /etc/ssh/sshd_config}}&lt;br /&gt;
&lt;br /&gt;
2. Configure mount options:&lt;br /&gt;
&lt;br /&gt;
Edit {{path|/etc/fstab}} and Add `nosuid`, `nodev`, and `noexec` options to non-root partitions as follows:{{Cat|/etc/fstab|...&lt;br /&gt;
/dev/sda1 /home ext4 defaults,nosuid,nodev,noexec 0 2&lt;br /&gt;
...}}&lt;br /&gt;
&lt;br /&gt;
== Network security ==&lt;br /&gt;
&lt;br /&gt;
1. Disable unnecessary services: {{cmd|doas rc-update del &amp;lt;service_name&amp;gt;&lt;br /&gt;
doas rc-service &amp;lt;service_name&amp;gt; stop}}&lt;br /&gt;
&lt;br /&gt;
2. Configure {{Pkg|iptables}} firewall by installing and enabling it as follows:{{cmd|doas apk add iptables&lt;br /&gt;
doas rc-service iptables start&lt;br /&gt;
doas rc-update add iptables}}&lt;br /&gt;
&lt;br /&gt;
Create a basic firewall ruleset by adding Example rules to {{Path|/etc/iptables/rules.v4}} as follows:{{Cat|/etc/iptables/rules.v4|*filter&lt;br /&gt;
:INPUT DROP [0:0]&lt;br /&gt;
:FORWARD DROP [0:0]&lt;br /&gt;
:OUTPUT ACCEPT [0:0]&lt;br /&gt;
-A INPUT -i lo -j ACCEPT&lt;br /&gt;
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT&lt;br /&gt;
-A INPUT -p tcp --dport 22 -j ACCEPT&lt;br /&gt;
COMMIT }}&lt;br /&gt;
&lt;br /&gt;
== Logging and auditing ==&lt;br /&gt;
&lt;br /&gt;
1. Configure system logging by editing {{path|/etc/rsyslog.conf}} to ensure all log files are being captured. An example configuration is shown below:{{Cat|/etc/rsyslog.conf|*.info;mail.none;authpriv.none;cron.none /var/log/messages&lt;br /&gt;
authpriv.* /var/log/secure&lt;br /&gt;
mail.* -/var/log/maillog&lt;br /&gt;
cron.* /var/log/cron}}&lt;br /&gt;
&lt;br /&gt;
2. Set up audit rules by editing the {{path|/etc/audit/rules.d/audit.rules}} files and adding example rules as follows:{{Cat|/etc/audit/rules.d/audit.rules|-w /etc/passwd -p wa -k passwd_changes&lt;br /&gt;
-w /etc/shadow -p wa -k shadow_changes&lt;br /&gt;
-w /etc/group -p wa -k group_changes}}&lt;br /&gt;
&lt;br /&gt;
== Apply kernel and service hardening ==&lt;br /&gt;
&lt;br /&gt;
1. Disable unused filesystems by editing {{path|/etc/modprobe.d/disable-filesystems.conf}} and add the following lines: {{Cat|/etc/modprobe.d/disable-filesystems.conf|install cramfs /bin/true&lt;br /&gt;
install freevxfs /bin/true&lt;br /&gt;
install jffs2 /bin/true&lt;br /&gt;
install hfs /bin/true&lt;br /&gt;
install hfsplus /bin/true&lt;br /&gt;
install squashfs /bin/true&lt;br /&gt;
install udf /bin/true&lt;br /&gt;
install vfat /bin/true}}&lt;br /&gt;
&lt;br /&gt;
2. Configure kernel parameters by editing the {{path|/etc/sysctl.conf}} and adding or updating the following parameters:{{Cat|/etc/sysctl.conf|&amp;lt;nowiki&amp;gt;net.ipv4.ip_forward = 0&lt;br /&gt;
net.ipv4.conf.all.accept_source_route = 0&lt;br /&gt;
net.ipv4.conf.all.accept_redirects = 0&lt;br /&gt;
net.ipv4.conf.all.secure_redirects = 0&lt;br /&gt;
net.ipv4.conf.all.log_martians = 1&lt;br /&gt;
net.ipv4.conf.default.log_martians = 1&lt;br /&gt;
net.ipv4.icmp_echo_ignore_broadcasts = 1&lt;br /&gt;
net.ipv4.icmp_ignore_bogus_error_responses = 1&lt;br /&gt;
net.ipv4.tcp_syncookies = 1&lt;br /&gt;
net.ipv4.conf.all.send_redirects = 0&lt;br /&gt;
net.ipv4.conf.default.send_redirects = 0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Regular maintenance ==&lt;br /&gt;
&lt;br /&gt;
1. Set up regular updates by creating a cron job by editing {{Path|crontab}} using the command {{ic|crontab -e}} such that  updates are applied daily at 2 AM. The output of {{ic|crontab -l}} appears as follows:{{Cat|/var/spool/cron/crontabs/root|...&lt;br /&gt;
0 2 * * * apk update &amp;amp;&amp;amp; apk upgrade }}&lt;br /&gt;
2. Review and monitor logs regularly and ensure that logs are rotated and reviewed frequently: {{cmd|doas logrotate /etc/logrotate.conf}}&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
This process provides a foundation for securing an Alpine Linux system. Regular reviews and updates, along with compliance with the latest security guidelines, are essential to maintaining a secure environment.&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Dilettant</name></author>
	</entry>
</feed>