OpenBSD SSH Configuration - Beginner Guide
OpenBSD SSH Configuration - Beginner Guide
SSH (Secure Shell) is the primary way to remotely manage OpenBSD. Proper configuration is essential for security.
Default SSH Settings
When you first install OpenBSD and log in:
Default root password: root (change it immediately!)
Default user: root (log in as root, then create your own user)
Default SSH port: 22
Default authentication: Password authentication is enabled initially
Step 1: Log In and Become Familiar
After installation, you'll be at a prompt as root.
Your first task: Change the root password:
passwd
Enter new password, verify it
Create a regular user: (replace yourname with your name)
adduser
Follow prompts: full name, room number, etc.
Set a password for your user:
passwd yourname
Enter and verify new password
Step 2: Configure SSH for Security
Now let's make SSH more secure. The main configuration file is /etc/sshd_config.
Key Security Changes
1. Disable root login:
Find the line: #PermitRootLogin yes
Change to: PermitRootLogin no
Why: Prevents anyone from logging in as root, even with correct password.
2. Disable password authentication:
Find: #PasswordAuthentication yes
Change to: PasswordAuthentication no
Why: Forces use of SSH keys, which are much more secure.
3. Enable key-based authentication:
Find: #PubkeyAuthentication yes (usually already enabled)
Why: Uses mathematical keys instead of passwords.
Generate SSH Key Pair
On your local computer (not the OpenBSD server):
ssh-keygen -t ed25519 -C "yourname@yourdomain"
Press Enter to accept default location, optionally add a passphrase
This creates two files:
~/.ssh/id_ed25519 - Private key (keep this secret!)
~/.ssh/id_ed25519.pub - Public key (can be shared)
Copy Public Key to OpenBSD
ssh-copy-id -i ~/.ssh/id_ed25519.pub root@your-openbsd-ip
Enter your root password when prompted
Now try logging in:
ssh root@your-openbsd-ip
You should be logged in without being asked for password
Step 3: Test and Secure
Test passwordless login: Try SSH again - you shouldn't be asked for password.
Disable password authentication: Now that keys work, set PasswordAuthentication no in /etc/sshd_config.
Important: Test the key login first! If you disable passwords too early and keys don't work, you'll be locked out.
Restart SSH service: rcctl restart sshd
Common Beginner Problems
Problem: "Connection refused"
Solution: Ensure sshd is running: rcctl status sshd. Start it: rcctl start sshd.
Problem: "Permission denied (publickey)."
Solution: Check that ssh-keygen created the key, and ssh-copy-id copied it correctly. Verify file permissions: chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys.
Problem: "Permission denied".
Solution: You might still have password authentication enabled. Try logging in with password first, then disable it after keys work.
Ready for more SSH configuration? Proceed to Lesson 12: SSH Key Authentication.
Article author: Arthur Isaev