SFTP Class
Properties Methods Events Configuration Settings Errors
The SFTP component can be used to transfer files to and from SFTP servers using the SFTP Protocol.
Class Name
IPWorksSSH_SFTP
Procedural Interface
ipworksssh_sftp_open(); ipworksssh_sftp_close($res); ipworksssh_sftp_register_callback($res, $id, $function); ipworksssh_sftp_get_last_error($res); ipworksssh_sftp_get_last_error_code($res); ipworksssh_sftp_set($res, $id, $index, $value); ipworksssh_sftp_get($res, $id, $index); ipworksssh_sftp_do_append($res); ipworksssh_sftp_do_config($res, $configurationstring); ipworksssh_sftp_do_decodepacket($res, $encodedpacket); ipworksssh_sftp_do_deletefile($res, $filename); ipworksssh_sftp_do_doevents($res); ipworksssh_sftp_do_download($res); ipworksssh_sftp_do_encodepacket($res, $packet); ipworksssh_sftp_do_getsshparam($res, $payload, $field); ipworksssh_sftp_do_getsshparambytes($res, $payload, $field); ipworksssh_sftp_do_interrupt($res); ipworksssh_sftp_do_listdirectory($res); ipworksssh_sftp_do_makedirectory($res, $newdir); ipworksssh_sftp_do_queuefile($res, $localfile, $remotefile); ipworksssh_sftp_do_removedirectory($res, $dirname); ipworksssh_sftp_do_renamefile($res, $newname); ipworksssh_sftp_do_resetqueue($res); ipworksssh_sftp_do_setsshparam($res, $payload, $fieldtype, $fieldvalue); ipworksssh_sftp_do_sshlogoff($res); ipworksssh_sftp_do_sshlogon($res, $sshhost, $sshport); ipworksssh_sftp_do_updatefileattributes($res); ipworksssh_sftp_do_upload($res);
Remarks
The SFTP class is the SSH-enabled equivalent of the IP*Works! FTP class. The main difference is the introduction of a set of new properties and events that deal with SSH security. The SSHHost and SSHPort properties specify the SSH server to use. The SSHUser and SSHPassword properties allow the client to authenticate itself with the server. The SSHServerAuthentication event and/or SSHAcceptServerHostKey property allow you to check the server identity. Finally, the SSHStatus event provides information about the SSH handshake.
The SFTP class implements a standard SSH File Transfer client.
The first step in using the class is specifying the SSHHost, SSHUser and SSHPassword. The file to upload to or download from is given by the RemoteFile property. The file to download to or upload from is specified by LocalFile. The current path in the server is specified by the RemotePath property.
If LocalFile is set to something other than an empty string, then files are received in LocalFile, otherwise the data is received through the Transfer event. StartTransfer and EndTransfer are fired at the beginning and end of transmission.
Directory listings are received through the DirList event.
Property List
The following is the full list of the properties of the class with short descriptions. Click on the links for further details.
Connected | Triggers a connection or disconnection. |
DirListCount | The number of records in the DirList arrays. |
DirListEntry | This property contains the raw entry as received from the server. |
DirListFileName | This property shows the file name in the last directory listing. |
DirListFileSize | This property shows the file size in the last directory listing. |
DirListFileTime | This property shows the file time in the last directory listing. |
DirListIsDir | This property specifies whether entries in the last directory listing are directories. |
FileAccessTime | The number of milliseconds since 12:00:00 AM January 1, 1970 when this file was last accessed. |
FileACL | A string containing an Access Control List (ACL). |
FileAllocationSize | The size, in bytes, that this file consumes on disk. |
FileAttributeBits | AttributeBits and AttributeBitsValid each contain a bitmask representing attributes of the file on the SFTP server. |
FileAttributeBitsValid | AttributeBits and AttributeBitsValid each contain a bitmask representing attributes of the file on the SFTP server. |
FileCreationTime | The number of milliseconds since 12:00:00 AM January 1, 1970 when this file was created. |
FileType | The type of file. |
FileGroupId | The id of the group that has access rights this file. |
FileIsDir | Whether or not the file represented by these attributes is a directory. |
FileModifiedTime | The number of milliseconds since 12:00:00 AM January 1, 1970 that this file was last modified. |
FileOwnerId | The user id of this file's owner. |
FilePermissions | A 32-bit integer containing the a POSIX-compatible file permission bitmask. |
FileSize | The total size, in bytes, of this file. |
FileExists | Returns true if the file specified by RemoteFile exists on the remote server. |
FirewallAutoDetect | This property tells the component whether or not to automatically detect and use firewall system settings, if available. |
FirewallType | This property determines the type of firewall to connect through. |
FirewallHost | This property contains the name or IP address of firewall (optional). |
FirewallPassword | This property contains a password if authentication is to be used when connecting through the firewall. |
FirewallPort | This property contains the TCP port for the firewall Host . |
FirewallUser | This property contains a user name if authentication is to be used connecting through a firewall. |
Idle | The current status of the component. |
LocalFile | The path to a local file for download/upload. If the file exists, it is overwritten. |
LocalHost | The name of the local host or user-assigned IP interface through which connections are initiated or accepted. |
LocalPort | The TCP port in the local host where IPPort binds. |
Overwrite | Whether or not the component should overwrite files during transfer. |
RemoteFile | The name of the remote file for uploading, downloading, etc. |
RemotePath | The current path in the SFTP server. |
SSHAcceptServerHostKeyEncoded | The certificate (PEM/base64 encoded). |
SSHAuthMode | The authentication method to be used the component when calling SSHLogon . |
SSHCertEncoded | The certificate (PEM/base64 encoded). |
SSHCertStore | The name of the certificate store for the client certificate. |
SSHCertStorePassword | If the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store. |
SSHCertStoreType | The type of certificate store for this certificate. |
SSHCertSubject | The subject of the certificate used for client authentication. |
SSHCompressionAlgorithms | A comma-separated list containing all allowable compression algorithms. |
SSHEncryptionAlgorithms | A comma-separated list containing all allowable compression algorithms. |
SSHHost | The address of the SSH host. |
SSHPassword | The password for SSH password-based authentication. |
SSHPort | The port on the SSH server where the SSH service is running; by default, 22. |
SSHUser | The username for SSH authentication. |
StartByte | The offset in bytes at which to begin the Upload or Download. |
Timeout | A timeout for the component. |
Method List
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
Append | Append data from LocalFile to a remote file RemoteFile on an SFTP server. |
Config | Sets or retrieves a configuration setting . |
DecodePacket | Decodes a hex-encoded SSH packet. |
DeleteFile | Remove a file specified by FileName from an SFTP server. |
DoEvents | Processes events from the internal message queue. |
Download | Download a RemoteFile from an SFTP server. |
EncodePacket | Hex encodes an SSH packet. |
GetSSHParam | Used to read a field from an SSH packet's payload. |
GetSSHParamBytes | Used to read a field from an SSH packet's payload. |
Interrupt | Interrupt the current method. |
ListDirectory | List the current directory specified by RemotePath on an SFTP server. |
MakeDirectory | Create a directory on an SFTP server. |
QueueFile | Adds a file to the transfer queue. |
RemoveDirectory | Remove a directory specified by DirName from an SFTP server. |
RenameFile | Change the name of RemoteFile to NewName . |
ResetQueue | Resets the queue of files to be transferred. |
SetSSHParam | Used to write a field to the end of a payload. |
SSHLogoff | Logoff from the SSH server. |
SSHLogon | Logon to the SSHHost using the current SSHUser and SSHPassword . |
UpdateFileAttributes | Instructs the component to send the FileAttributes to the server. |
Upload | Upload a file specified by LocalFile to an SFTP server. |
Event List
The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.
Connected | Fired immediately after a connection completes (or fails). |
ConnectionStatus | Fired to indicate changes in connection state. |
DirList | Fired when a directory entry is received. |
Disconnected | Fired when a connection is closed. |
EndTransfer | Fired when a file completes downloading/uploading. |
Error | Information about errors during data delivery. |
SSHCustomAuth | Fired when the component is doing custom authentication. |
SSHKeyboardInteractive | Fired when the component receives a request for user input from the server. |
SSHServerAuthentication | Fired after the server presents its public key to the client. |
SSHStatus | Shows the progress of the secure connection. |
StartTransfer | Fired when a file starts downloading/uploading. |
Transfer | Fired during file download/upload. |
Configuration Settings
The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.
AllowBackslashInName | Whether backslashes are allowed in folder and file names. |
FiletimeFormat | Specifies the format to use when returning filetime strings. |
IgnoreFileMaskCasing | Controls whether or not the file mask is case sensitive. |
LocalEOL | When TransferMode is set, this specifies the line ending for the local system. |
ServerEOL | When TransferMode is set, this specifies the line ending for the remote system. |
MaxFileData | Specifies the maximum payload size of an SFTP packet. |
ProtocolVersion | The highest allowable SFTP version to use. |
PreserveFileTime | Preserves the file's timestamps during transfer. |
TransferMode | The transfer mode (ASCII or Binary). |
UseServerFileTime | Controls if the file time returned from the server is converted to local time or not. |
ReadLink | This settings returns the target of a specified symbolic link. |
RealTimeUpload | Enables real time uploading. |
RealTimeUploadAgeLimit | The age limit in seconds when using RealTimeUpload. |
SimultaneousTransferLimit | The maximum number of simultaneous file transfers. |
ClientSSHVersionString | The SSH version string used by the component. |
SignedSSHCert | The CA signed client public key used when authenticating. |
SSHAcceptServerCAKey | The CA public key that signed the server's host key. |
SSHAcceptAnyServerHostKey | If set the component will accept any key presented by the server. |
SSHAcceptServerHostKeyFingerPrint | The fingerprint of the server key to accept. |
SSHKeyExchangeAlgorithms | Specifies the supported key exchange algorithms. |
SSHMacAlgorithms | Specifies the supported Mac algorithms. |
SSHKeyRenegotiate | Causes the component to renegotiate the SSH keys. |
KeyRenegotiationThreshold | Sets the threshold for the SSH Key Renegotiation. |
KerberosRealm | The fully qualified domain name of the Kerberos Realm to use for GSSAPI authentication. |
KerberosDelegation | If true, asks for credentials with delegation enabled during authentication. |
KerberosSPN | The Kerberos Service Principal Name of the SSH host. |
LogSSHPackets | If true, detailed SSH packet logging is performed. |
MaxPacketSize | The maximum packet size of the channel, in bytes. |
MaxWindowSize | The maximum window size allowed for the channel, in bytes. |
PreferredDHGroupBits | The size (in bits) of the preferred modulus (p) to request from the server. |
ConnectionTimeout | Sets a separate timeout value for establishing a connection. |
FirewallAutoDetect | Tells the component whether or not to automatically detect and use firewall system settings, if available. |
FirewallHost | Name or IP address of firewall (optional). |
FirewallPassword | Password to be used if authentication is to be used when connecting through the firewall. |
FirewallPort | The TCP port for the FirewallHost;. |
FirewallType | Determines the type of firewall to connect through. |
FirewallUser | A user name if authentication is to be used connecting through a firewall. |
KeepAliveTime | The inactivity time in milliseconds before a TCP keep-alive packet is sent. |
KeepAliveInterval | The retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received. |
Linger | When set to True, connections are terminated gracefully. |
LingerTime | Time in seconds to have the connection linger. |
LocalHost | The name of the local host through which connections are initiated or accepted. |
LocalPort | The TCP port in the local host where the component binds. |
MaxLineLength | The maximum amount of data to accumulate when no EOL is found. |
MaxTransferRate | The transfer rate limit in bytes per second. |
RecordLength | The length of received data records. |
TCPKeepAlive | Determines whether or not the keep alive socket option is enabled. |
UseIPv6 | Whether to use IPv6. |
TcpNoDelay | Whether or not to delay when sending packets. |
AbsoluteTimeout | Determines whether timeouts are inactivity timeouts or absolute timeouts. |
FirewallData | Used to send extra data to the firewall. |
InBufferSize | The size in bytes of the incoming queue of the socket. |
OutBufferSize | The size in bytes of the outgoing queue of the socket. |
CodePage | The system code page used for Unicode to Multibyte translations. |