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
        • Enabling Serial Console Login
        • Connect with cu
          • Using cu
          • Named Connections
        • Using a Serial Console at Boot
        • USB Serial Adapters
        • Testing Serial Ports
          • Checking Device Presence
          • Performing a Loopback Test
          • Monitoring Port Usage
          • Checking Kernel Messages
        • Serial Parameters and Flow Control
        • Kernel Debugging over Serial
        • Using OpenBSD as a Console Server
          • Hardware Setup
          • Connecting to Devices
          • Managing Multiple Connections
          • Optional: Enabling Login on Serial Ports
          • Security Considerations

        Serial Communication

        Synopsis #

        Use serial connections to administer headless systems, reach network-device consoles, or debug hardware. OpenBSD provides cu for outgoing connections, /etc/ttys for serial logins, and /etc/boot.conf settings for boot and kernel console output.

        Enabling Serial Console Login #

        On OpenBSD, serial ports are typically available as /dev/tty00, /dev/tty01, and so on. To enable login on a serial port, modify the /etc/ttys file.

        To configure the first serial port (tty00) for login:

        tty00   "/usr/libexec/getty std.115200"   vt220   on secure
        

        This entry instructs init to launch getty(8) on /dev/tty00 using the std.115200 entry from gettytab(5). The terminal type vt220 is appropriate for most serial terminals. The secure keyword allows root logins on this line.

        To activate the change:

        doas kill -HUP 1
        

        This signals the init(8) process to reload its configuration and spawn getty on the specified line.

        Ensure the serial port is not already in use by another process. Use fstat or ps to confirm.

        Connect with cu #

        The OpenBSD base system includes cu(1) for serial connections. tip is not part of the OpenBSD base system.

        Using cu #

        Use cu to connect directly to a serial device. To open a connection with /dev/tty00 at 9600 baud:

        doas cu -l /dev/cua00 -s 9600
        

        To exit the session, type ~. at the beginning of a new line.

        Named Connections #

        Use cu for both direct connections and named entries in a remote database. A direct invocation:

        doas cu -l /dev/cua00 -s 9600
        

        The remote database is not installed by default. Create it if needed, following cu(1), or use direct -l and -s arguments. A reusable entry in /etc/remote:

        console:\
        	:dv=/dev/cua00:br#9600:pa=none:
        

        Then connect using:

        doas cu console
        

        The escape sequence to exit is the same: ~. on a new line.

        Using a Serial Console at Boot #

        To configure OpenBSD to use a serial port for bootloader and kernel messages, edit /etc/boot.conf.

        To enable serial console output via the first serial port (com0, corresponding to /dev/tty00):

        stty com0 115200
        set tty com0
        

        This will redirect output from the bootloader and kernel to the serial port, at the explicitly selected 115200 baud.

        When interacting with a system through a USB-to-serial adapter from another machine, use cu:

        doas cu -l /dev/cuaU0 -s 115200
        

        Interrupt the bootloader and enter:

        stty com0 115200
        set tty com0
        boot
        

        This will direct both boot and kernel output to the serial interface.

        USB Serial Adapters #

        Modern systems often lack traditional RS-232 ports. OpenBSD supports a wide variety of USB-to-serial adapters through drivers such as:

        • ucom(4) — generic USB serial interface
        • uplcom(4) — Prolific-based devices
        • umodem(4) — USB modems
        • uvscom(4) — SUNTAC serial devices

        When an adapter is connected, the kernel will log its detection:

        uplcom0 at uhub1 port 2: Prolific Technology USB-Serial Controller
        ucom0 at uplcom0
        

        Device nodes will appear as:

        • /dev/cuaU0 — for outgoing connections (cu)
        • /dev/ttyU0 — for incoming connections (e.g., login)

        To connect at 115200 baud:

        doas cu -l /dev/cuaU0 -s 115200
        

        Testing Serial Ports #

        Serial ports may be tested using various techniques.

        Checking Device Presence #

        Ensure the relevant device node exists:

        doas ls -l /dev/tty00
        

        Performing a Loopback Test #

        Physically connect the transmit and receive pins (e.g., pins 2 and 3 on a DB9 connector), then:

        doas cu -l /dev/cua00 -s 9600
        

        Typing characters should cause them to echo back to the screen.

        Monitoring Port Usage #

        Use fstat to determine which process, if any, is using a serial device:

        fstat | grep tty00
        

        List processes holding serial devices with fstat:

        fstat | grep -E 'tty|cua'
        

        Checking Kernel Messages #

        Inspect kernel logs for detected serial interfaces:

        com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
        

        USB-based adapters will show ucom, uplcom, or similar device lines.

        Serial Parameters and Flow Control #

        Serial communications depend on consistent settings across both endpoints. Common parameters include:

        • Baud rate: such as 9600, 19200, or 115200
        • Data bits: typically 8 (cs8)
        • Parity: none (-parenb), or even, odd
        • Stop bits: usually 1 (-cstopb)
        • Flow control: none, XON/XOFF, or RTS/CTS

        To manually configure these settings:

        doas stty -f /dev/tty00 115200 cs8 -cstopb -parenb
        

        This sets 115200 baud, 8 data bits, 1 stop bit, and no parity on /dev/tty00.

        Kernel Debugging over Serial #

        Serial communication is essential when using the OpenBSD kernel debugger (ddb) on headless or embedded systems, or when debugging kernel panics remotely. When a serial console is properly configured, ddb output and input can be redirected to the serial line.

        To enable kernel debugging over serial, the system must first be configured to use a serial console. This includes:

        1. Configuring /etc/boot.conf:

          To redirect console output to the first serial port (com0, typically /dev/tty00):

          stty com0 115200
          

        set tty com0

        
        2. **Ensuring `ddb` is enabled**:
        
        The default OpenBSD kernel includes `ddb`. To ensure it is accessible, confirm the following `sysctl` values:
        
        ```sh
        doas sysctl ddb.console ddb.panic
        

        Example output:

        ddb.console=1
        ddb.panic=1
        

        These settings mean that:

        • ddb.console=1: the kernel debugger is available from the console
        • ddb.panic=1: the kernel will enter ddb on a panic

        To make these settings persistent, add the following to /etc/sysctl.conf:

        ddb.console=1
        ddb.panic=1
        
        1. Using the debugger from serial:

          Once configured, when the system panics or ddb is manually entered (e.g., with sysctl ddb.trigger=1), the prompt will appear on the serial console. Commands such as trace, ps, show registers, and reboot may be entered.

          ddb> trace
          ddb> ps
          ddb> reboot
          
        2. Triggering ddb manually:

          Use the following command to break into the debugger manually (for testing or debugging):

          doas sysctl ddb.trigger=1
          

          This will drop the system into ddb from the current console. When using a serial console, the prompt will be visible over the serial line.

        3. Handling systems without local displays:

          On systems lacking VGA or framebuffer output, such as many embedded platforms, serial console access is the only way to interact with ddb. For this reason, early configuration of serial console output is critical during system bring-up or platform porting.

        A serial console permits state inspection and crash-log capture when the system’s display or normal network access is unavailable.

        Root-run cu permits local command escapes. Do not grant unrestricted doas cu to an account intended to have only serial-console access. Design device permissions and any restricted invocation around that requirement; cu -r blocks local filesystem operations and command execution.

        Using OpenBSD as a Console Server #

        An OpenBSD system can serve as a reliable console server, providing serial access to one or more remote devices such as switches, headless servers, firewalls, or embedded platforms. This setup is often used in data centers, labs, or remote deployments where out-of-band management is required.

        Hardware Setup #

        Most modern systems lack traditional serial ports but can be equipped using USB-to-serial adapters. OpenBSD supports many such adapters via drivers like uplcom, umodem, uvscom, and ucom. Multi-port PCI or PCIe serial cards (e.g., based on ns8250) are also supported via the com(4) driver.

        Upon connecting a USB serial adapter, the device will be visible as /dev/cuaU0, /dev/cuaU1, etc. Kernel messages can be inspected using dmesg:

        uplcom0 at uhub1 port 3: Prolific USB-Serial Controller
        ucom0 at uplcom0
        

        Use a proper null modem cable between the OpenBSD system and the device under management.

        Connecting to Devices #

        Each serial port can be accessed interactively using cu:

        doas cu -l /dev/cuaU0 -s 115200
        

        To simplify access, define named entries in /etc/remote:

        router1:\
        	:dv=/dev/cuaU0:br#115200:pa=none:
        switch1:\
        	:dv=/dev/cuaU1:br#9600:pa=none:
        

        Then connect with:

        doas cu router1
        

        Managing Multiple Connections #

        For operators managing several devices simultaneously, tmux can be used to provide one pane per serial session. Example:

        tmux
        cu -l /dev/cuaU0 -s 9600   # Pane 1
        cu -l /dev/cuaU1 -s 115200 # Pane 2
        

        Alternatively, a wrapper script or shell alias can provide quick access.

        Optional: Enabling Login on Serial Ports #

        If inbound access to the OpenBSD console server is required via serial, /etc/ttys can be modified to start a login session on each port:

        ttyU0   "/usr/libexec/getty std.115200"   vt220   on secure
        ttyU1   "/usr/libexec/getty std.115200" vt220   on secure
        

        Reload the configuration:

        doas kill -HUP 1
        

        This enables users to connect to the OpenBSD system via serial for administrative tasks.

        Security Considerations #

        To ensure proper isolation:

        • Use doas.conf to restrict which users can run cu
        • Configure login.conf to limit resource usage
        • Log access and commands through a restricted shell or shell wrapper
        • Avoid getty on ports where only outbound connections are needed

        Access to the console server itself should be protected by ssh with key-based authentication, and physical access should be limited where possible.

        Report a bug
        • Synopsis
        • Enabling Serial Console Login
        • Connect with cu
          • Using cu
          • Named Connections
        • Using a Serial Console at Boot
        • USB Serial Adapters
        • Testing Serial Ports
          • Checking Device Presence
          • Performing a Loopback Test
          • Monitoring Port Usage
          • Checking Kernel Messages
        • Serial Parameters and Flow Control
        • Kernel Debugging over Serial
        • Using OpenBSD as a Console Server
          • Hardware Setup
          • Connecting to Devices
          • Managing Multiple Connections
          • Optional: Enabling Login on Serial Ports
          • Security Considerations