Using FTP OLE Automation

image\rwnprg32.gif Sample Code: Making a Secure Shell Connection

 

The following sample example makes a Secure Shell connection and transfers a file. In this example:

· SSHSchemeName is used to specify the name of an SSH config scheme. In this example, the sample scheme (also shown) is configured to require Public Key authentication.

· Because no value for UseSFTP is specified, the default value (False) is used, which means that Reflection uses the FTP protocol (sent securely through the SSH tunnel) to transfer the file. Although SSH authentication happens transparently in this example using public keys, users will see a prompt for authenticating to the FTP server.

· In the Open method statement, the PassiveMode parameter set to True. This is required for any connection that forwards FTP through the SSH tunnel.

Sample Code

Sub GetFileSSHScheme()

' Create the Reflection FTP Object and create a log file

Dim Ftp As ReflectionFTP3

Set Ftp = CreateObject("Reflection.FTP")

Ftp.StartLog "C:\test\ftplog.txt"

 

'Set up a Secure Shell connection using settings in the specified scheme

Ftp.UseSSH = True

Ftp.SSHSchemeName = "RequireUserKeyAuthentication"

 

'Connect to the host in passive mode

Ftp.Open "myhost", "myusername", , , , True

 

'Transfer the file

Ftp.ReceiveFile "C:\test\", "test.txt", rcASCII, rcAskUser

 

'Close the connection, close the log, and free up the memory

Ftp.Close

Ftp.StopLog

Set Ftp = Nothing

End Sub

Sample Config File Scheme

Host RequireUserKeyAuthentication

KbdInteractiveAuthentication no

ChallengeResponseAuthentication no

PasswordAuthentication no

IdentityFile "C:\mypath\mykey"

#EndHost