openSUSE server: sudo, SSH keys and a hardened sshd
Make sudo use your own password, log in with keys only, and lock down sshd without locking yourself out.
Part 3 of 10 in openSUSE home server setup. Last updated
In short: On openSUSE, sudo asks for root's password by default; install sudo-policy-wheel-auth-self and add yourself to wheel to use your own. Copy an ed25519 key with ssh-copy-id, then put PasswordAuthentication no, KbdInteractiveAuthentication no and PermitRootLogin no in a drop-in such as /etc/ssh/sshd_config.d/10-hardening.conf. Check with sudo sshd -t, reload sshd, and test in a second terminal before you close the first. Reach SSH from outside through WireGuard, never through a port forward.
An admin user and sudo on openSUSE
openSUSE's default sudo rule asks for the password of the target user, which is root
(Defaults targetpw). That works, but it means everyone who administers the box
shares the root password. The cleaner setup is the one Fedora uses: members of
wheel type their own password.
sudo zypper install sudo-policy-wheel-auth-self # needs root (root's password this once)
sudo usermod -aG wheel alice
# log out and back in, then:
id # wheel is listed
sudo -k; sudo true # now asks for alice's password The details of users, groups and sudo are in the users, groups and sudo guide.
Key login first
On your laptop, not on the server:
ssh-keygen -t ed25519 -C "alice@laptop" # accept the path, set a passphrase
ssh-copy-id alice@192.168.1.10 # asks the account password one last time
ssh alice@192.168.1.10 # should log in without that password
The SSH key and config helper walks through the
same steps and also gives you a short ~/.ssh/config entry, so
ssh homeserver is enough.
What ssh-keygen leaves behind, made here with an empty passphrase in a scratch folder (use a passphrase for a real key):
$ ssh-keygen -q -t ed25519 -N '' -C user@laptop -f ./id_ed25519_demo
$ ls -l id_ed25519_demo*
-rw------- 1 user user 399 Sep 28 06:36 id_ed25519_demo
-rw-r--r-- 1 user user 93 Sep 28 06:36 id_ed25519_demo.pub
$ ssh-keygen -lf id_ed25519_demo.pub
256 SHA256:LDEWcTDpj2emLaZoaLEIQDJiwiWahmO7hH4BjZkvpgw user@laptop (ED25519) Real output on openSUSE Tumbleweed, OpenSSH 10.5, 2026-09-28; user and host names and addresses redacted.
The private key is readable by you alone (-rw-------); only the .pub
file goes to the server. The fingerprint is what the server shows in its log when you log in.
Harden sshd with a drop-in file
Do not edit the vendor file. Create a drop-in instead (needs root):
sudoedit /etc/ssh/sshd_config.d/10-hardening.conf # /etc/ssh/sshd_config.d/10-hardening.conf
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
AllowUsers alice PasswordAuthentication noandKbdInteractiveAuthentication no: keys only.PermitRootLogin no: log in as yourself and use sudo, so the log shows who did what.AllowUsers: only the listed accounts may log in over SSH at all. Add every user who needs SSH, including service users you log in as.
Why 10-: for most options sshd keeps the first value it reads, and it
reads drop-ins in name order. A low number beats a later file that says the opposite. All
options are in sshd_config(5).
A test with a scratch copy: the main file includes the drop-in first and then says
PasswordAuthentication yes. sshd -T prints the settings sshd would
really use, and the drop-in wins:
$ cat sshd_config
Include /etc/ssh/10-hardening.conf
HostKey /etc/ssh/hostkey
PasswordAuthentication yes
PidFile none
$ sshd -T -f ./sshd_config | grep -E '^(PermitRootLogin|PasswordAuthentication|KbdInteractiveAuthentication|AllowUsers) '
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
AllowUsers alice Real output on openSUSE Tumbleweed, OpenSSH 10.5, 2026-09-28; user and host names and addresses redacted.
Test without locking yourself out
sudo sshd -t # syntax check; silent means fine
sudo sshd -T | grep -Ei 'passwordauth|kbdinteractive|permitroot'
sudo systemctl reload sshd # existing sessions stay open Keep your current session open. In a second terminal, log in again. Then prove that passwords are really refused:
ssh -o PubkeyAuthentication=no alice@192.168.1.10
# expected: Permission denied (publickey). Only when both tests pass, close the first session.
Keep port 22 off the internet
Key-only SSH is strong, but a port forward still invites the whole internet to knock. Reach the server from outside through WireGuard instead: the router forwards one UDP port, and SSH stays on the LAN and the tunnel. The Cockpit over WireGuard guide shows the firewalld zones for that setup, and the firewalld basics guide explains zones in general.
Common mistakes
Switching off passwords before the key works
Always log in with the key first, then disable passwords. If you did lock yourself out, the local console still accepts your password: SSH settings do not apply there.
Permission denied (publickey) for a key that is on the server
sshd ignores keys when the permissions are too open. Fix them as that user:
chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys. The server
side reason is in journalctl -u sshd -n 20.
Typing your own password where sudo wants root's
Without the wheel policy, openSUSE's sudo asks for root's password and answers a wrong one with "Sorry, try again". Install the policy package from the first section, or use root's password.
Frequently asked questions
Where is sshd_config on openSUSE?
Current openSUSE ships the default in /usr/etc/ssh/sshd_config and reads your changes from /etc/ssh/sshd_config.d/*.conf. Older installs have /etc/ssh/sshd_config itself. A drop-in file works on both; sudo sshd -T prints the settings sshd actually uses.
Why does my PasswordAuthentication no not work?
For most sshd options the first value read wins, and drop-ins are read in name order. Another drop-in with a lower name (for example from cloud-init) that sets PasswordAuthentication yes wins over yours. Name your file 10-something.conf and check with sudo sshd -T | grep -i passwordauthentication.
Do I need fail2ban?
Not when SSH only accepts keys and is only reachable from your LAN or through WireGuard. Password guessing cannot succeed against key-only login; fail2ban then only keeps the log quieter.