Sample code for 30+ languages & platforms
VB.NET

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 VB.NET Downloads

VB.NET
Dim success As Boolean = False

'  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.

Dim sftp As New Chilkat.SFtp

'  Step 1: Connect the SSH transport.  Port 22 is the usual port.
Dim port As Integer = 22
success = sftp.Connect("sftp.example.com",port)
If (success = False) Then
    Debug.WriteLine(sftp.LastErrorText)
    Exit Sub
End If


'  Begin keyboard-interactive authentication.  The returned XML describes the server's prompts.
Dim infoRequestXml As String = sftp.StartKeyboardAuth("mySshLogin")
If (sftp.LastMethodSuccess = False) Then
    Debug.WriteLine(sftp.LastErrorText)
    Exit Sub
End If

Debug.WriteLine(infoRequestXml)

'  Answer the prompt(s) with ContinueKeyboardAuth, then call InitializeSftp.

sftp.Disconnect()