OpenBSD Handbook

    Theme
    • Part I. Install & Configure
      • Introduction to OpenBSD
      • Installing OpenBSD
      • The X Window System
      • Networking on OpenBSD
      • System Configuration
      • OpenBSD Basics
      • Managing Software: Packages and Ports
    • Part II. Daily Operations
      • OpenBSD Desktop Environments
      • Multimedia
      • Printing
      • Linux Compatibility
      • Windows Compatibility
      • Games
    • Part III. System Administration
      • Virtualization
      • Storage and File Systems
      • Updating and Upgrading
      • Localization
      • The OpenBSD Boot Process
      • Security
    • Part IV. Networking & Daemons
      • Services
        • Database
          • MariaDB
          • PostgreSQL
          • Redis
          • memcached
        • Directory
          • YP (NIS)
          • LDAP
        • File
          • NFS
          • Samba
        • FTP Services
          • ftpd
          • ProFTPD
          • vsftpd
          • Pure-FTPd
          • TFTP
        • Mail
          • OpenSMTPD Mail Server
          • Dovecot IMAP and POP3 Server
          • Postfix
          • Exim
          • Rspamd
        • Name
          • Unbound DNS Resolver
          • NSD Authoritative DNS Server
          • BIND DNS Server
        • Networking
          • OpenBGPD
          • rad
          • DHCP on OpenBSD
          • slaacd
        • Web
          • Apache HTTP Server
          • nginx Web Server
          • OpenBSD httpd Web Server
          • relayd Reverse Proxy
        • Logging
          • syslogd
        • Monitoring
          • SNMP
        • Remote Access
          • Audit OpenSSH
          • OpenSSH Server
        • File Synchronization
          • rsync
        • Messaging
          • RabbitMQ Message Broker
        • Time
          • NTP Time Synchronization
        • Load Balancing
          • Build Redundant Load-Balanced Gateways
          • Load Balance Services with NAT or DSR
          • Build an HA HTTPS Load Balancer
      • PF
        • pfctl cheat sheet
        • PF Anchors
        • PF Filter Rules
        • PF Forwarding
        • PF Lists and Macros
        • PF Load Balancing
        • PF Logging
        • PF NAT
        • PF Options
        • PF Policies
        • PF Shortcuts
        • PF Tables
      • Advanced Networking
        • High Availability and State Replication
        • Multi-WAN and Policy-Based Routing
        • VPN and Cryptographic Tunneling
        • Classic and Lightweight Tunnels
        • IPv6 at Scale
        • QoS and Traffic Shaping
        • MPLS and Label Distribution
        • Network Services at Scale
        • Virtualization and Host Networking
        • Large-Scale L2 and L3 Design
        • Telemetry, Logging, and Flow Export
        • Hardening and Operational Safety
        • Reference Architectures
        • Troubleshooting Playbooks
      • Serial Communication
    • Part V. Miscellaneous
      • Virtualization Cheat Sheet
      • OpenBSD Cheatsheet
      • How-to Guides
        • Installation and First Boot
          • Complete the First 30 Minutes After Installation
          • Check Hardware Compatibility Before Installing
          • Bootstrap Wi-Fi Firmware Without Ethernet
          • Run OpenBSD as a Virtual Machine Guest
          • Install OpenBSD on a VPS or Cloud Server
          • Install OpenBSD with Full-Disk Encryption
          • Dual-Boot OpenBSD on a UEFI System
          • Automate OpenBSD Installation with Autoinstall and PXE
        • Desktops and Laptops
          • Set Up OpenBSD as a Laptop or Workstation
          • Configure Laptop Power Management
          • Troubleshoot Web Browsers on OpenBSD
          • Use Plan 9 Tools on OpenBSD
          • Build a Minimal Desktop with suckless Tools
          • Install Z shell (zsh)
        • Networking and Remote Access
          • Create an Administrator Account with doas and SSH Keys
          • Configure Secure Remote Access with OpenSSH
          • Use FIDO Security Keys with OpenSSH
          • Configure Wi-Fi Roaming and Wired Failover
          • Troubleshoot PF, NAT, and Routing
          • Route Multiple VLANs with PF
          • Configure a Road-Warrior WireGuard VPN
          • Route IPv6 Networks without NAT
          • Test OpenBGPD with Two Providers
          • Unlock an Internal Service with an SSH Key
          • Build a Simple Router and Firewall
        • Servers and Services
          • Set Up WordPress on OpenBSD
          • Build a Mail Server with OpenSMTPD, Dovecot, and Rspamd
        • Security, Maintenance and Recovery
          • Establish a Conservative Security Baseline
          • Recover Access and Reset the Root Password
          • Collect OpenBSD Diagnostic Evidence
          • Troubleshoot Package Installation and Update Failures
          • Schedule Recurring Maintenance
          • Monitor an OpenBSD System
          • Back Up and Restore an OpenBSD System
          • Configure softraid RAID1
          • Recover an OpenBSD System That Does Not Boot
        • Building, Automation and Virtual Machines
          • Manage OpenBSD with Ansible
          • Build Third-Party Software from Ports
          • Build OpenBSD from Source
          • Plan a Docker Workload Migration to OpenBSD
      • OpenBSD for Linux Users
      • OpenBSD for FreeBSD Users
      • OpenBSD for macOS Users
    • OpenBSD FAQ
    • OpenBSD Architectures
      • OpenBSD Package Search
        • Synopsis
        • Record the System Role
        • Establish Administrative Recovery First
        • Apply Supported Updates
        • Minimize Enabled Services and Packages
        • Restrict Network Exposure
        • Protect Secrets and Configuration
        • Preserve OpenBSD Security Mechanisms
        • Make Failure Visible and Recoverable

        Establish a Conservative Security Baseline

        Synopsis #

        OpenBSD begins with a small enabled-service set and integrated exploit mitigations. A useful security baseline preserves those defaults, restricts privileges, records changes, and provides a recovery procedure. It does not consist of an imported sysctl list, a third-party kernel, or disabling platform security mechanisms to make applications work.

        This guide establishes a conservative host baseline. Use the relevant Handbook chapter to configure each exposed service.

        Record the System Role #

        Document the host’s purpose, administrators, exposed services, management networks, data sensitivity, backup destination, and recovery path. Every enabled daemon, listening socket, package, privileged account, and PF exception should support that role.

        Capture the starting state:

        uname -a
          # Record release and architecture
        doas rcctl ls on
          # List daemons enabled through rc.d
        netstat -na -f inet
          # List IPv4 sockets without name lookups
        netstat -na -f inet6
          # List IPv6 sockets without name lookups
        doas pfctl -sr
          # Display the active filter policy
        

        Keep this inventory with change records, not in a public report when it reveals internal addresses or services.

        Establish Administrative Recovery First #

        Create and verify a named administrator account, SSH key, and doas(1) policy before restricting remote access. Create an Administrator Account provides the complete workflow.

        Maintain an independent recovery route such as an authorized console, provider console, or tested local access path. Keep an existing SSH session open while changing SSH or PF policy, then prove a new session works before closing it.

        Apply Supported Updates #

        Use signed OpenBSD mechanisms for each maintenance layer:

        doas syspatch
          # Apply available base-system errata patches on a supported release
        doas fw_update
          # Update installed firmware packages
        doas pkg_add -u
          # Update installed third-party packages
        

        Release upgrades are separate and must follow the current official upgrade guide. See Update and Upgrade OpenBSD . Unsupported releases do not become secure through local hardening alone.

        Minimize Enabled Services and Packages #

        Review enabled daemons and installed packages:

        doas rcctl ls on
          # Review every enabled base and package daemon
        pkg_info -mz
          # Record manually installed package stems
        

        Disable a daemon only after confirming that the host role and dependent services do not require it:

        doas rcctl disable exampled
          # Prevent the daemon from starting at future boots
        doas rcctl stop exampled
          # Stop the current instance after dependency review
        

        exampled is a placeholder, not an OpenBSD service. Do not paste the example unchanged.

        Remove unused packages with pkg_delete(1) after reviewing reverse dependencies and retained configuration. Fewer installed components reduce maintenance work, but indiscriminate removal can break the documented host role.

        Restrict Network Exposure #

        Bind services to the required addresses and apply an explicit pf.conf(5) policy. A host policy should normally:

        • block unsolicited inbound traffic by default;
        • allow required new connections with stateful pass rules; packets matching an existing state do not require a separate established-traffic rule;
        • expose only required ports on intended interfaces;
        • restrict management services to administrative sources where practical;
        • retain ICMP and ICMPv6 required for correct network operation;
        • log selected policy failures without creating an unbounded log stream.

        Parse a complete ruleset before loading it:

        doas pfctl -nf /etc/pf.conf
          # Reject syntax errors without changing the active ruleset
        doas pfctl -f /etc/pf.conf
          # Load the rules only after parsing and recovery review
        

        Use Configure Secure Remote Access with OpenSSH and the PF chapters for complete policies. Port changes and address hiding do not replace authentication or patching.

        Protect Secrets and Configuration #

        Review ownership and mode on private keys, password databases, VPN configuration, backup credentials, and automation material. Use a restrictive creation mode before writing a secret:

        doas test -e /etc/example.secret || doas install -o root -g wheel -m 600 /dev/null /etc/example.secret
        

        /etc/example.secret is a placeholder. The existence test prevents truncation. Apply the pattern only to a configuration file whose daemon documentation requires it.

        Do not grant broad supplementary groups, device access, or passwordless doas merely to bypass one application error. Treat an automation account with unrestricted passwordless doas as a root credential.

        Preserve OpenBSD Security Mechanisms #

        pledge(2) and unveil(2) are application mechanisms, not global tuning switches. Package-provided policies should remain enabled unless a maintained package README requires a narrow local exception.

        Do not raise kern.securelevel or set immutable file flags as a generic checklist item. These mechanisms can prevent package maintenance, PF changes, log rotation, or recovery. The Security chapter explains their administrative tradeoffs.

        Make Failure Visible and Recoverable #

        Direct root mail to an actively read mailbox, review failed daemons and logs, and establish capacity and update checks. Monitor an OpenBSD System provides the baseline.

        Back up data and locally changed configuration to independent storage, then perform test restores. Protect backup credentials and encryption material separately from the host. Back Up and Restore an OpenBSD System describes backup creation and restore testing.

        After each policy change, verify the intended service from its client network and verify that an unintended path remains blocked. Record the command, configuration revision, result, and rollback method.

        Report a bug
        • Synopsis
        • Record the System Role
        • Establish Administrative Recovery First
        • Apply Supported Updates
        • Minimize Enabled Services and Packages
        • Restrict Network Exposure
        • Protect Secrets and Configuration
        • Preserve OpenBSD Security Mechanisms
        • Make Failure Visible and Recoverable