SSH Interactive Auth Sample Server¶
This tool 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.
Features¶
- OpenSSH Server: Runs a standard OpenSSH server on port 2222.
- Keyboard-Interactive Auth: Configured to require
keyboard-interactiveauthentication. - Google Authenticator: Uses
libpam-google-authenticatorto simulate 2FA. - Pre-configured User: Creates a user
testuserwith passwordtestpassand a pre-generated 2FA secret.
Location¶
The source code for this tool is located in the ssh-interactive-auth-sample-server/ directory of the project root.
Usage¶
Using Make (Recommended)¶
-
Build and Start:
To use a registry mirror: -
View Logs:
-
Stop:
-
Clean:
Using Docker Compose Directly¶
-
Start:
-
Stop:
Testing Connection¶
To test the connection, use an SSH client:
You will be prompted for:
1. Password: testpass
2. Verification code: You need the current TOTP code.
Getting the Verification Code¶
Since 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):
Use this key in a TOTP app (like Google Authenticator) or a CLI tool (likeoathtool) to generate the code.Example with
oathtool: -
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):
Integration with Autossh Tunnel¶
To test autossh-cli auth with this server:
- Start the sample server.
- Add a tunnel configuration to your
config.yaml: - Start the autossh container.
-
Authenticate via one of the following methods:
Option A: CLI
Option B: Web Panel (in-browser terminal)
If
WS_BASE_URLis configured on the web container, click the Start button on the interactive tunnel row in the web panel. An xterm.js terminal modal will open for you to enter your credentials. See Web Panel - WebSocket Configuration for setup details.