Tcl
Tcl
Start SSH Tunnel Keyboard-Interactive Authentication
See more SSH Tunnel Examples
Demonstrates the Chilkat SshTunnel.StartKeyboardAuth method, which begins keyboard-interactive authentication. The only argument is the login name. It returns XML describing the server's prompts, which are answered with ContinueKeyboardAuth.
Background: Keyboard-interactive is the prompt-driven authentication method: the server sends one or more questions — a password, a one-time code, a security question — and the client answers each. This is how a tunnel supports two-factor and other challenge-response schemes. The returned XML says exactly what to ask and whether to mask the input.
Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# Demonstrates the SshTunnel.StartKeyboardAuth method, which begins keyboard-interactive
# authentication. The only argument is the login name. It returns XML describing the server's
# prompts, which are answered with ContinueKeyboardAuth.
set tunnel [new_CkSshTunnel]
# The tunnel forwards accepted local connections to this destination through the SSH server.
CkSshTunnel_put_DestHostname $tunnel "db.internal.example.com"
CkSshTunnel_put_DestPort $tunnel 5432
# Connect to the SSH server. This performs the TCP/proxy connection and SSH handshake, but
# does not authenticate yet.
set sshPort 22
set success [CkSshTunnel_Connect $tunnel "ssh.example.com" $sshPort]
if {$success == 0} then {
puts [CkSshTunnel_lastErrorText $tunnel]
delete_CkSshTunnel $tunnel
exit
}
# Begin keyboard-interactive authentication. The returned XML describes the server's prompts.
set infoRequestXml [CkSshTunnel_startKeyboardAuth $tunnel "mySshLogin"]
if {[CkSshTunnel_get_LastMethodSuccess $tunnel] == 0} then {
puts [CkSshTunnel_lastErrorText $tunnel]
delete_CkSshTunnel $tunnel
exit
}
puts "$infoRequestXml"
# Answer the prompt(s) with ContinueKeyboardAuth, then call BeginAccepting.
set waitForThreadExit 1
set success [CkSshTunnel_CloseTunnel $tunnel $waitForThreadExit]
if {$success == 0} then {
puts [CkSshTunnel_lastErrorText $tunnel]
delete_CkSshTunnel $tunnel
exit
}
delete_CkSshTunnel $tunnel