Description
Is this a new feature request?
- I have searched the existing issues
Wanted change
Add support for OTP / 2FA authentication (e.g. via PAM with Google Authenticator or compatible modules) for SSH connections in the container.
This could be implemented as an optional feature (e.g. environment variable like ENABLE_OTP=true) that:
- installs and enables a PAM OTP module (such as libpam-google-authenticator)
- configures /etc/pam.d/sshd
- updates sshd_config to support keyboard-interactive authentication
Reason for change
Currently, the container supports password and/or public key authentication, but does not provide built-in support for a second authentication factor.
Adding OTP would significantly improve security, especially for:
- internet-exposed SSH services
- homelab setups
- production environments requiring stronger authentication
At the moment, users must build custom images and manually configure PAM, which adds complexity and reduces usability.
Providing native support (or an officially documented option) would make 2FA adoption much easier and more consistent.
Proposed code change
High-level approach:
Install PAM module:
apt-get update && apt-get install -y libpam-google-authenticator
Update /etc/pam.d/sshd:
auth required pam_google_authenticator.so
Update sshd_config:
ChallengeResponseAuthentication yes
UsePAM yes
AuthenticationMethods publickey,keyboard-interactive
Optional:
- Add env variable
ENABLE_OTP=true - Conditionally apply configuration at container startup
- Optionally allow per-user setup (user runs google-authenticator inside container)
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
github-actions commentedon Apr 13, 2026
Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.
LinuxServer-CI commentedon May 14, 2026
This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.
Add optional OTP (2FA) access
Add optional OTP (2FA) access
SckyzO commentedon Aug 3, 2026
Reopening: the issue was closed by the stale bot, not on merit, and I now have a working implementation to propose.
Branch: https://github.com/SckyzO/docker-openssh-server/tree/pr/healthcheck-and-otp-2fa
It is opt-in through
OTP_ACCESS. With the variable unset, nothing changes: no PAM stack is written,sshd_configis untouched, and key-only login behaves exactly as today. A PR follows.SckyzO commentedon Aug 3, 2026
This was closed by the stale bot rather than on merit, and I could not reopen it, so leaving a note here instead.
I have a working implementation and am opening a PR against it.
It is strictly opt-in through
OTP_ACCESS. With the variable unset nothing changes: no PAM stack is written,sshd_configis untouched, and key-only login behaves exactly as today.Branch: https://github.com/SckyzO/docker-openssh-server/tree/pr/healthcheck-and-otp-2fa
LinuxServer-CI commentedon Sep 3, 2026
This issue is locked due to inactivity