aboutsummaryrefslogtreecommitdiffstats
path: root/openbsd-image/scripts/harden-root.sh
blob: 423b536bdedc815188e843fcac8e47a06fb6964d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
#
# DESCRIPTION: Harden root user access by
#   - Ensuring only root:wheel can change /etc/doas.conf
#   - Remove the root user's password
#   - Disable root user login via SSH
#
# ASSUMPTIONS:
#   - Run as root.
#
# USAGE:
#   ./harden-root.sh
set -e

main() {
  chown root:wheel /etc/doas.conf
  chmod 0640 /etc/doas.conf
  usermod -p '*' root
  sed -i 's/^PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
  rcctl reload sshd
}

main "$@"