Dockerized OpenSSH server with keyboard-interactive auth for testing 2FA flows.
1.4K
This project provides a Dockerized SSH server configured to require keyboard-interactive authentication (simulating 2FA). It is designed for testing SSH clients that need to handle interactive prompts, such as autossh-cli auth.
keyboard-interactive authentication.libpam-google-authenticator to simulate 2FA.testuser with password testpass and a pre-generated 2FA secret.Build and Start:
make up
To use a registry mirror:
REGISTRY_MIRROR=docker.1ms.run make up
View Logs:
make logs
Stop:
make down
Clean:
make clean
Start:
docker compose up -d --build
Stop:
docker compose down
To test the connection, use an SSH client:
ssh -p 2222 testuser@localhost
You will be prompted for:
testpassSince the 2FA secret is generated inside the container, you have two options:
Get the Secret Key: Run the following command to see the secret key (first line):
docker exec -it ssh-interactive-auth cat /home/testuser/.google_authenticator | head -n 1
Use this key in a TOTP app (like Google Authenticator) or a CLI tool (like oathtool) to generate the code.
Example with oathtool:
SECRET=$(docker exec ssh-interactive-auth head -n 1 /home/testuser/.google_authenticator)
oathtool --totp -b "$SECRET"
Scan the QR Code: If you want to scan the QR code with your phone, you can view the generated file content (which might contain a URL or ASCII QR code if generated with those options, though the current setup is minimal):
docker exec -it ssh-interactive-auth cat /home/testuser/.google_authenticator
Note: The current setup script uses -C which might not output the QR code to the file. Using the secret key is more reliable for testing.
sshd_config:
PasswordAuthentication noChallengeResponseAuthentication yesUsePAM yesAuthenticationMethods keyboard-interactivePAM:
config/pam.d/sshd to use pam_google_authenticator.so.MIT
Content type
Image
Digest
sha256:a0130bb0b…
Size
84.8 MB
Last updated
8 months ago
docker pull oaklight/ssh-interactive-auth-sample-server