Xbase++
Xbase++
Start SFTP Keyboard-Interactive Authentication
See more SFTP Examples
Demonstrates the Chilkat SFtp.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: rather than assuming a single password, the server sends one or more questions — a password, a one-time code, a security question — and the client answers each. This is how SFTP supports two-factor and other challenge-response schemes. The returned XML tells you exactly what to ask and whether to mask the input.
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oSftp
LOCAL nPort
LOCAL cInfoRequestXml
nSuccess := 0
// Demonstrates the SFtp.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.
oSftp := CreateObject("Chilkat.SFtp")
// Step 1: Connect the SSH transport. Port 22 is the usual port.
nPort := 22
nSuccess := oSftp:Connect("sftp.example.com", nPort)
IF (nSuccess == 0)
? oSftp:LastErrorText
oSftp:destroy()
RETURN
ENDIF
// Begin keyboard-interactive authentication. The returned XML describes the server's prompts.
cInfoRequestXml := oSftp:StartKeyboardAuth("mySshLogin")
IF (oSftp:LastMethodSuccess == 0)
? oSftp:LastErrorText
oSftp:destroy()
RETURN
ENDIF
? cInfoRequestXml
// Answer the prompt(s) with ContinueKeyboardAuth, then call InitializeSftp.
oSftp:Disconnect()
oSftp:destroy()