OPNsense ships with its SSH server switched off, and turning it on takes one checkbox. Doing it safely takes a few more: key login instead of passwords, a listener that stays off the WAN, and an admin account that isn’t root. Those extra steps are where most people get stuck, usually on a bare Permission denied (publickey) that says nothing about the cause.
Below you enable SSH on OPNsense from the web GUI, log in with an ed25519 key and bind the daemon to LAN only. A named admin then gets shell access and sudo before root login goes off. We also cover the post-quantum ML-DSA host key that appeared during the 26.7 series. Every step below was run on OPNsense 26.7.9 in November 2026, with an Ubuntu 24.04 workstation as the SSH client.
Prerequisites
You need admin access to the OPNsense web GUI and a Linux, macOS or Windows machine on the LAN side with an OpenSSH client. The lab used these addresses, so swap in your own wherever they appear:
- Firewall
fw01, LAN address10.0.1.10, OPNsense 26.7.9 - Workstation
10.0.1.50, Ubuntu 24.04, OpenSSH 9.6p1 - Admin user
josphatcreated later in this guide
If the firewall is still on an older release, update OPNsense from the web UI or console first, because the SSH host key behaviour changed twice inside the 26.7 series. Building a test box to practise on is quick if you install OPNsense on Proxmox VE.
Enable SSH on OPNsense
The SSH settings live on the same page as the web GUI settings, which is why they are easy to miss. Go to System > Settings > Administration and scroll past the Web GUI block until you reach the Secure Shell section. On a fresh install every box there is unticked and Listen Interfaces reads All (recommended).

- 1Enable Secure Shell
- 2Permit root user login
- 3Listen Interfaces
Work through the section in the order below. Leave Permit password login unticked, because once a key is in place you will never need it. An SSH server that refuses passwords cannot be brute forced, so the bots that hammer port 22 on every public address get nothing to guess at.
- Tick Enable Secure Shell.
- Tick Permit root user login for now, so you can test the key as root before any other account exists.
- Open Listen Interfaces and pick LAN.
- Leave SSH port on 22 and click Save at the bottom of the page.
There is no separate start button for the service. Saving the page writes /usr/local/etc/ssh/sshd_config and restarts sshd, so the daemon was already answering on port 22 by the time the page reloaded. That also means every later change on this page takes effect the moment you save it, which matters when you start removing access. The section looked like this after the save:

A first login attempt from the workstation proves the server is up and that passwords are off. With no key on either side, sshd rejects the session before it ever asks for a password:
ssh [email protected]
The only method on offer is publickey, which is exactly what we want at this stage:
[email protected]: Permission denied (publickey).
Before SSH was enabled, my lab client got ssh: connect to host 10.0.1.10 port 22: Connection timed out instead. If you still get no answer after saving, confirm the Save went through, then check Listen Interfaces with the sockstat check in the LAN section further down, run from console option 8 since SSH is not answering yet.
Generate an SSH key on your workstation
Use ed25519 unless something old on your network still needs RSA. Its public key is short enough to paste into the OPNsense field on one line, and every OpenSSH release from the last decade supports it. Skip this step if ~/.ssh/id_ed25519.pub already exists, because the command would ask to overwrite it.
ssh-keygen -t ed25519 -C "josphat@workstation"
Press Enter to accept the default path and set a passphrase when prompted. The run on the workstation produced this:
Generating public/private ed25519 key pair.
Your identification has been saved in /home/josphat/.ssh/id_ed25519
Your public key has been saved in /home/josphat/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:Cjn7lVi2IUzFrv9bNxnPo9xuX1qxB4E44VqXzEvu6bs josphat@workstation
Print the public half so you can copy it into the GUI. Expect a single line starting with ssh-ed25519, and only this .pub file ever goes onto the firewall. The private key stays on the workstation, so a leaked config backup gives an attacker nothing they can log in with:
cat ~/.ssh/id_ed25519.pub
On Windows the same ssh-keygen command works in PowerShell, and the file lands in the .ssh folder of your Windows profile. PuTTY users can pick a client from our list of SSH and serial clients for Windows.
Add the key to root and log in
OPNsense stores authorized keys per user in its config, not in a file you edit by hand. Open System > Access > Users, click the pencil next to root, scroll to the bottom of the dialog and paste the public key into Authorized Keys. Several keys go one per line.

Click Save. OPNsense writes the key out straight away, so the login works on the next attempt without any service restart. Connect again from the workstation:
ssh [email protected]
Root does not land in a shell. Instead it gets the same console menu you see on the serial or VGA console, along with the host key fingerprints for the box:

Check the ED25519 fingerprint in the banner against what your client showed on first connect. With default client settings, that first connection stops at an “authenticity of host can’t be established” prompt, so read the fingerprint off the firewall’s own console before you type yes. If they match, nobody sat between you and the firewall. Option 8 drops to a root shell and option 12 runs the console updater, which is handy when the web GUI is the thing that is broken.
Create a non-root admin user for SSH
Logging in as root works, but the OPNsense manual itself says root login “is generally discouraged” and suggests a separate user who switches to root when needed. That also gives you per-person audit lines in the log instead of a shared root account. In System > Access > Users, click + and fill in a username and password.

- 1Login shell
- 2Group membership
- 3Authorized Keys
Three fields decide whether this user can actually SSH in. The screenshot above was taken with the first one deliberately left wrong:
- Login shell: set it to
/bin/shor/bin/csh - Group membership:
admins - Authorized Keys: the same public key, or the user’s own
We saved the user with Login shell on Default (none for all but root) first to see what happens. The GUI accepted it without a warning, yet the key login failed with the same message as before:
[email protected]: Permission denied (publickey).
The firewall’s log tells the real story. With the Default shell, OPNsense keeps the user in its config for web GUI logins but never creates a system account, so sshd has nobody to match the key against:
<38>1 2026-11-11T17:50:21+00:00 fw01.internal sshd-session 74686 - [meta sequenceId="135"] Invalid user josphat from 10.0.1.50 port 40930
Edit the user again, change Login shell to /bin/sh and save. That single change is what makes OPNsense create the account and write the key to /home/josphat/.ssh/authorized_keys.

Now log in as the new user and check what it is on the box:
ssh [email protected] id
Membership of admins maps the user onto the wheel group. That matters because the generated sshd config only lets wheel in, so the group box does double duty as the SSH allow list. Note the primary group too, since it decides who owns the files this user creates:
uid=2000(josphat) gid=0(wheel) groups=0(wheel)
You can confirm that rule on the firewall itself. The lines below come from the config OPNsense writes, read after root login was turned off later in this guide:
grep -E "^(PermitRootLogin|PasswordAuthentication|AllowGroups|Port) " /usr/local/etc/ssh/sshd_config
Keep AllowGroups wheel in mind. sshd refuses any account whose groups don’t include wheel, so a shell user left out of admins won’t get in no matter which key it holds:
Port 22
AllowGroups wheel
PermitRootLogin no
PasswordAuthentication no
Edits to that file do not last, because OPNsense rewrites it from the GUI settings on every save. Change SSH behaviour on the Administration page instead.
Allow sudo for the admin user
A shell user is not root, and OPNsense ships with sudo disallowed for everybody. Before you take root login away, give the new user a way back up, or every root task means a trip back to the web GUI. Trying sudo now shows the default:
ssh -t [email protected] sudo whoami
sudo takes the password and then refuses anyway:
Password:
josphat is not in the sudoers file.
Go back to System > Settings > Administration and scroll to the Authentication section near the bottom. Set Sudo to Ask password, leave the group selector under it on wheel, and save.

The other choice, No password, is convenient for automation but turns a stolen key into instant root. Ask password means an attacker needs the key and the user’s GUI password, so one leaked laptop is not enough to rewrite your rules. If a script really needs passwordless sudo, give it a dedicated user rather than relaxing the setting for every admin. Run the same command again:
ssh -t [email protected] "sudo whoami; sudo grep -v ^# /usr/local/etc/sudoers.d/20-opnsense"
The user is root after the password prompt, and the sudoers file OPNsense generated holds a single rule for wheel:
Password:
root
%wheel ALL=(ALL) ALL
The password sudo asks for is the user’s own, the one set in the user dialog, not the root password.
Turn off root login
With a working sudo user, root over SSH is only extra attack surface. Root is the one account name every attacker already knows, and a root session leaves no trace of which admin opened it. Back in the Secure Shell section, untick Permit root user login and save. Keep your current josphat session open while you test from a second terminal, so a mistake doesn’t lock you out.
ssh [email protected]
The key on root’s account is still valid, but sshd turns it away:
[email protected]: Permission denied (publickey).
Your client prints the same message as the no-key case, so check the firewall side to tell them apart. On OPNsense the sshd lines go to the audit log, readable with sudo grep sshd /var/log/audit/latest.log:
<38>1 2026-11-11T17:53:49+00:00 fw01.internal sshd-session 67668 - [meta sequenceId="364"] ROOT LOGIN REFUSED FROM 10.0.1.50 port 42752
If you ever lose the admin user’s key, fix it from the web GUI: paste a new key under System > Access > Users, or tick root login back on for a moment. The physical or serial console is the fallback for when the GUI is also out of reach, and option 3 there resets the root password. If Password protect the console menu is ticked, the console asks for a password before the menu appears. Keep that path tested on hardware you can reach. On a VM the hypervisor console serves the same purpose.
Keep SSH listening on LAN only
The GUI labels All (recommended) as the default for Listen Interfaces, and the manual’s own note on the field reads “Leave empty to listen globally. Use with extreme care.” The difference is easy to see with sockstat, run from the admin user’s shell on the firewall. I set All briefly to compare. With it selected, sshd binds every IPv4 address on the box, WAN included:
sudo sockstat -4 -l -p 22
The wildcard address *:22 is the one to worry about:
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
root sshd 47534 7 tcp4 *:22 *:*
After setting it back to LAN and saving, the same command shows sshd on the LAN IPv4 address and loopback only:
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
root sshd 28243 7 tcp4 10.0.1.10:22 *:*
root sshd 28243 10 tcp4 127.0.0.1:22 *:*
The default WAN rules still block inbound SSH when the daemon listens everywhere, so All is not an open door by itself. It does mean one careless WAN pass rule exposes port 22 to the internet. Binding to LAN removes that failure mode. For remote access, a VPN is the better path: our guide to Tailscale on OPNsense gets you SSH over the tailnet without opening anything.
Check the ML-DSA host key on OPNsense 26.7
Look at the console banner again and you’ll spot a fourth host key type, MLDSA44-ED25519. According to the OPNsense 26.7 release notes, 26.7.3 began offering this post-quantum hybrid key with OpenSSH 10.5p1. The 26.7.8 notes then warn that OpenSSH 10.6 rejects ML-DSA keys generated with 10.5, so they “have to be deleted and regenerated once”, which happens on reboot or a service restart.
The 26.7.9 box in this lab runs OpenSSH 10.6p2 and holds a freshly generated ML-DSA key next to the classic three. These fingerprints differ from the banner shot earlier because I deleted and regenerated the host keys for the troubleshooting section below. Listing the fingerprints on the firewall shows all four:
for f in /conf/sshd/*.pub; do ssh-keygen -lf $f; done
On a box that generated its ML-DSA key on 26.7.3 to 26.7.7, that line is the one that changes at the first reboot or sshd restart after updating to 26.7.8 or later. The other three survive it:
256 SHA256:lZGXOEYzJHuq4oelTpc0jUtC3coFsd0cBOfABWqn99c [email protected] (ECDSA)
256 SHA256:1KtO1/Zt+++lsFq7WiGFrbcc2eAE7NcRwzDYL0xLrVk [email protected] (ED25519)
512 SHA256:BSJotn1Kz9WDMTmOpiVoaCRN881OiM5ZvCf/+y/5pkU [email protected] (MLDSA44-ED25519)
3072 SHA256:netdt++xXv5+mlLZD/Q0b/eqkmMLfJgouptBrqfjzzQ [email protected] (RSA)
Older clients simply ignore the new type. The Ubuntu 24.04 workstation runs OpenSSH 9.6p1, so it negotiated ED25519 and had no use for the ML-DSA key. Whatever key type your client records, compare it with the console banner before you accept it.
Fix common OPNsense SSH errors
All three errors below were reproduced on the lab firewall. Two of them print the same client message, so the fix starts with the firewall log rather than guesswork.
Permission denied (publickey)
This one message came back for three different causes in testing, and sshd’s group rule adds a fourth. Read /var/log/audit/latest.log on the firewall to see which one you’ve hit:
- No
Invalid userorREFUSEDline: the key isn’t in the user’s Authorized Keys Invalid user: Login shell is still DefaultROOT LOGIN REFUSED: Permit root user login is offnot allowed because none of user's groups are listed in AllowGroups: the user is outsideadmins, so check its groups from another admin session
Password login being off is the reason none of these fall back to a password prompt. Resist ticking Permit password login to “fix” it, because that hides the real cause and weakens the box.
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED
You’ll see this after reinstalling OPNsense, restoring a config onto new hardware, or any event that regenerates the files in /conf/sshd/. We reproduced it by deleting those keys and restarting sshd, which is what a reinstall does in effect:

Do not clear it blindly. If nobody touched the firewall, treat it as a possible interception and stop there. If you did, compare the new fingerprint in the error with the one on the OPNsense console banner, then drop the stale entries:
ssh-keygen -R 10.0.1.10
It removes every key type stored for that address and keeps a backup copy of the file:
# Host 10.0.1.10 found: line 1
# Host 10.0.1.10 found: line 2
# Host 10.0.1.10 found: line 3
/home/josphat/.ssh/known_hosts updated.
Original contents retained as /home/josphat/.ssh/known_hosts.old
Before reconnecting, you can fetch the new key and check it against the banner from the workstation:
ssh-keyscan -t ed25519 10.0.1.10 2>/dev/null | ssh-keygen -lf -
The fingerprint matches the ED25519 line the firewall printed for its own key, so the next login can safely accept it:
256 SHA256:1KtO1/Zt+++lsFq7WiGFrbcc2eAE7NcRwzDYL0xLrVk 10.0.1.10 (ED25519)
Your client asks once to confirm the new key on the next login, then stores it again in known_hosts.
user is not in the sudoers file
The Sudo option under Authentication is still on Disallow, or the user is not in admins. Set it to Ask password as shown earlier and save, then retry from a fresh session. Do this before unticking root login, because a sudo-less admin and no root login leaves no root shell over SSH until you change it in the web GUI.
With those pieces in place, the firewall accepts keys only, from LAN only, for named admins who sudo with a password. That’s the setup worth keeping. If you’re still choosing hardware for a permanent install, our roundup of pfSense and OPNsense hardware covers fanless mini PCs, and the OPNsense vs pfSense mini PC comparison has throughput numbers from the same class of box.