WinSCP and Two Factor Authentication With One Time SMS Password

Advertisement

wecanseeformiles
Joined:
Posts:
1
Location:
Warwickshire

WinSCP and Two Factor Authentication With One Time SMS Password

I'm successfully connecting to a password protected SFTP site using the WinSCP GUI and also with a WinSCP Session in Excel VBA. However the client wants me to turn on at the SFTP site two factor authentication which sends a further one time code by SMS. I've done this and have no problems accessing the SFTP site via browser after logging in and entering the one time code that's SMS'd to me. I've searched your docs and have played around with both the GUI and the Excel VBA code but have no idea how to configure WinSCP to generate a further dialog box that allows entry of the one time code that's sent by SMS. For reference my VBA code is below. I've seen some suggestion that mySession.executecommand("AUTHTYPE") will generate some useful information but I can't even succeed in opening the session.
'PROC NAME:
'VerifyFTPConnection
'
'DESCRIPTION & COMMENTS:
'Returns True if WinSCP.Session successfully established to SFTP server and returns opened sftp session to calling routine.
'
'PARAMETERS:
'sessionOptions: session options for sftp session
'mySession: sftp session we are trying to open up
'strUser: user id for sftp session
'strPass: password for sftp session
'***************************************************************************
Public Function VerifyFTPConnection(ByRef sessionOptions As WinSCPnet.sessionOptions, ByRef mySession As WinSCPnet.Session, _
    ByVal strUser As String, ByVal strPass As String) As Boolean
On Error GoTo ErrorHandler
 
    Dim authType As String
    
    With sessionOptions
        .Protocol = Protocol_Ftp
        .hostname = "files.*******.com"
        .UserName = strUser
        .Password = strPass
       ' .PortNumber = 21
        .FtpSecure = FtpSecure.FtpSecure_Explicit
    End With
    
    mySession.Open sessionOptions
    
    'authType = mySession.executecommand("AUTHTYPE")
    'Debug.Print authType
        
    VerifyFTPConnection = True
        
    Exit Function
    
ErrorHandler:
End Function

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,837
Location:
Prague, Czechia

Re: WinSCP and Two Factor Authentication With One Time SMS Password

WinSCP .NET assembly does not support interactive authentication prompts.

Are you even able to connect with WinSCP GUI? What do you mean by "have no problems accessing the SFTP site via browser"? Do you mean "web browser"? The web browsers do not support SFTP.

Btw, you wrote about SFTP, but the code uses FTP.

Reply with quote

Advertisement

You can post new topics in this forum