Linux SSH and sudo
This page covers the built-in Linux SSH template: SSH and sudo on a Linux server, authenticated by OkYouIn
through pam_radius_auth. For RADIUS concepts see RADIUS.
Verified on
Section titled “Verified on”| Platform | Software | Modes | What was verified |
|---|---|---|---|
| Ubuntu | 26.04 (OpenSSH, pam_radius 3.0.0, sudo-rs 0.2.13) | password, MFA only, password + MFA | SSH and sudo with TOTP in the keyboard-interactive / sudo prompt; Web Push with number matching; MFA only after the local password (the local password is not sent to OkYouIn); SSH session accounting Start / Stop |
What works
Section titled “What works”| First factor | OkYouIn checks the password, or MFA only — after the SSH key (variant A) or after the local Linux password (variant B). |
| Second factor | TOTP, e-mail code, push (Web Push with number matching, Telegram) in the keyboard-interactive prompt. |
| Scope | Only members of a local group okyouin; every other account keeps its local login. |
| Accounting | SSH sessions: Start / Stop with session time. sudo has no session accounting. |
| Client IP | SSH sends the client address. sudo sends none, so network conditions do not match for sudo. |
Before you start
Section titled “Before you start”-
In OkYouIn, open Access ▸ Applications ▸ Add application and pick Linux SSH. Add the server’s address under Sources and choose the First factor. The Connect tab shows the files for the chosen mode with real values.
-
Keep a root session open for the whole change, and test both a key login and an OkYouIn login in new sessions before closing it.
Configure the server
Section titled “Configure the server”The examples use OkYouIn at 192.0.2.10 and the NAS-Identifier web-01.
-
Install pam_radius (Debian / Ubuntu: package
libpam-radius-auth). -
Add OkYouIn to
/etc/pam_radius_auth.confand make the file readable by root only (root:root, mode600):# server[:port] shared_secret timeout (s)192.0.2.10:1812 <SHARED-SECRET> 60 -
Create the group
okyouinand add the accounts that log in through OkYouIn. -
Edit
/etc/pam.d/sshdand/etc/pam.d/sudoand add the sshd drop-in/etc/ssh/sshd_config.d/10-okyouin.conffor your first-factor mode:/etc/pam.d/sshdand/etc/pam.d/sudo— replace@include common-authwith:auth [success=ignore default=1] pam_succeed_if.so quiet user ingroup okyouinauth [success=done new_authtok_reqd=done default=die] pam_radius_auth.so client_id=web-01@include common-auth/etc/ssh/sshd_config.d/10-okyouin.conf:Match Group okyouinKbdInteractiveAuthentication yesAuthenticationMethods keyboard-interactive/etc/pam.d/sshd— replace@include common-authwith:auth [success=ignore default=1] pam_succeed_if.so quiet user ingroup okyouinauth [success=done new_authtok_reqd=done default=die] pam_radius_auth.so force_prompt skip_passwd client_id=web-01@include common-auth/etc/ssh/sshd_config.d/10-okyouin.conf:Match Group okyouinKbdInteractiveAuthentication yesAuthenticationMethods publickey,keyboard-interactive/etc/pam.d/sshd— replace@include common-authwith:@include common-authauth [success=ignore default=1] pam_succeed_if.so quiet user ingroup okyouinauth required pam_radius_auth.so force_prompt skip_passwd client_id=web-01/etc/ssh/sshd_config.d/10-okyouin.conf:Match Group okyouinKbdInteractiveAuthentication yesAuthenticationMethods keyboard-interactiveIn MFA-only mode, sudo uses the local password, then the code —
/etc/pam.d/sudo:@include common-authauth [success=ignore default=1] pam_succeed_if.so quiet user ingroup okyouinauth required pam_radius_auth.so force_prompt skip_passwd client_id=web-01 -
Check with
sshd -t, thensystemctl reload ssh.
Rules that matter:
client_id=is required on everypam_radius_auth.soline. Without it pam_radius sends the PAM service name (sshd,sudo) as NAS-Identifier and OkYouIn does not accept the request.- MFA only: keep
force_prompt skip_passwd. Withoutforce_prompt, pam_radius reuses the password an earlier module already read and sends the local Linux password to the RADIUS server;skip_passwdalone does not stop that. With both, OkYouIn receives an empty password and asks only for the code. - The drop-in wins. sshd keeps the first value it reads, so a drop-in overrides the main
sshd_config(Ubuntu’s setsKbdInteractiveAuthentication noafter the include). Never setAuthenticationMethodsoutside theMatchblock: it would apply to every account, including your own admin and automation logins.UsePAM yes(the Debian / Ubuntu default) must stay on.
Accounting
Section titled “Accounting”Add the two session lines after @include common-session in /etc/pam.d/sshd:
session [success=ignore default=1] pam_succeed_if.so quiet user ingroup okyouinsession optional pam_radius_auth.so client_id=web-01pam_radius sends Accounting Start when the SSH session opens and Stop when it closes, with the session time; the sessions (user, client address, sshd PID as session ID) are on the application’s Sessions tab.
- Keep the
pam_succeed_ifline: without it every account sends accounting. - Keep
optional: withrequired, an unreachable OkYouIn refuses the SSH session after a successful login. - No Interim-Update, byte counters or disconnect cause: leave Interim interval (seconds) empty.
Reply attributes
Section titled “Reply attributes”Reply attributes from application rules have no effect on Linux: pam_radius 3.0.0 uses only
Management-Privilege-Level (with its privilege_level option) and Framed-IP-Address, as PAM variables.
BlastRADIUS
Section titled “BlastRADIUS”pam_radius 3.0.0 sends Message-Authenticator in every Access-Request, so Strict is safe and recommended for this application. New applications start at Standard.
Verify
Section titled “Verify”-
From another machine,
sshin as a member ofokyouinand complete the code prompt. -
Run
sudo -vand complete it again. -
Check Logging ▸ RADIUS log and the application’s Sessions tab.
-
Confirm that an account outside the
okyouingroup still logs in as before.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Likely cause |
|---|---|
| Login hangs for 60 seconds, then fails | The request is dropped — client_id= is missing on a pam_radius_auth.so line, the server’s address is not among the application’s Sources, or the secret is wrong. See Logging ▸ RADIUS log ▸ Dropped packets. The timeout in pam_radius_auth.conf is how long a dropped request blocks the login. |
Reject nas_identifier_mismatch | client_id= differs from the application’s NAS-Identifier. |
| ”Too many sign-in attempts, try again in N minutes” | Every SSH login and every sudo is one challenge of the per-user challenge limit (Access ▸ Settings ▸ RADIUS). |
| A wrong password at sudo locks the account sooner | sudo retries three times; each wrong password counts toward the account lockout. |