SSHFTPClient Class |
Namespace: EnterpriseDT.Net.Ftp.Ssh
The SSHFTPClient type exposes the following members.
Name | Description | |
---|---|---|
![]() | SSHFTPClient |
Default constructor.
|
Name | Description | |
---|---|---|
![]() | AuthenticationMethod |
Get or set the current authentication method being used.
(Inherited from SSHSCPClient.) |
![]() | ClientPrivateKeyBytes | (Inherited from SSHSCPClient.) |
![]() | ClientPrivateKeyFile | Path of the private key file used to authenticate the client (Inherited from SSHSCPClient.) |
![]() | ClientPrivateKeyPassphrase | Passphrase of the private key file. (Inherited from SSHSCPClient.) |
![]() | CloseStreamsAfterTransfer |
If true then streams are closed after a transfer has completed.
(Inherited from SSHSCPClient.) |
![]() | ControlPort |
The port on the server to which to connect the control-channel.
(Inherited from SSHSCPClient.) |
![]() | CountBeforeSleep |
Number of transfers before going to sleep
|
![]() | DefaultPermissions |
Set and get the default file creation mode permissions (in octal).
|
![]() | DeleteOnFailure |
Controls whether or not a file is deleted when a failure occurs.
(Inherited from SSHSCPClient.) |
![]() | DetectTransferMode |
If set to true, the transfer mode in operations involving multiple files is
automatically changed between ASCII and binary as appropriate.
(Overrides SSHSCPClientDetectTransferMode.) |
![]() | FilenameEncoding |
The character-encoding to use for file and directory names.
|
![]() | IsConnected |
Indicates whether the client is currently connected with the server.
(Overrides SSHSCPClientIsConnected.) |
![]() | IsResuming |
Returns true if the next transfer is to be resumed (i.e. Resume has been called).
(Inherited from SSHSCPClient.) |
![]() | KBIPrompts |
Array of prompts used for keyboard interactive (KBI) authentication.
(Overrides SSHSCPClientKBIPrompts.) |
![]() | KnownHosts | Manager of the list of known hosts used to authenticate the server. (Inherited from SSHSCPClient.) |
![]() | LastBytesTransferred |
The number of bytes transferred in the last transfer operation.
(Inherited from SSHSCPClient.) |
![]() | LastFileTransferred |
The remote name/path of the last file transferred.
(Inherited from SSHSCPClient.) |
![]() | LicenseKey |
The license key string.
(Inherited from SSHSCPClient.) |
![]() | LicenseOwner |
The license owner string.
(Inherited from SSHSCPClient.) |
![]() | LogTag | Log tag (Inherited from SSHSCPClient.) |
![]() | MaxPacketSize |
The SSH maximum packet size.
(Inherited from SSHSCPClient.) |
![]() | MaxQueuedReadRequests |
Maximum number of read requests to queue up (1=no queuing).
|
![]() | MaxTransferRate |
The maximum transfer rate in bytes per sec
(Inherited from SSHSCPClient.) |
![]() | ParallelTransferMode |
Uploads are by default in parallel mode, which is faster than
serial mode. This mode can be switched off if servers are unable
to deal with parallel mode.
|
![]() | Password | Password of account on the server or the passphrase of the private key file. (Inherited from SSHSCPClient.) |
![]() | PreferredCipherAlgorithms | Preferred algorithm(s) to use for encryption. (Inherited from SSHSCPClient.) |
![]() | PreferredCompressionAlgorithms | Preferred algorithm(s) to use for data compression (Inherited from SSHSCPClient.) |
![]() | PreferredHostKeyAlgorithms | Preferred algorithm(s) to use for server authentication via public key (Inherited from SSHSCPClient.) |
![]() | PreferredKeyExchangeMethods | Preferred methods to use for key exchange. (Inherited from SSHSCPClient.) |
![]() | PreferredMACAlgorithms | Preferred MAC algorithm(s) (Inherited from SSHSCPClient.) |
![]() | ProxySettings |
Settings for using proxies.
(Inherited from SSHSCPClient.) |
![]() | RemoteHost |
The domain-name or IP address of the SFTP server.
(Inherited from SSHSCPClient.) |
![]() | RetryAuth |
By default, authentication is retried automatically using a different method if it fails.
(Inherited from SSHSCPClient.) |
![]() | SendInitialWindowAdjust |
Determines whether a SSH_MSG_CHANNEL_WINDOW_ADJUST message should be
sent initially (true by default).
(Inherited from SSHSCPClient.) |
![]() | ServerCompatibility |
Controls various server compatibility features.
(Inherited from SSHSCPClient.) |
![]() | ServerValidation |
Controls the way in which remote servers are validated.
(Inherited from SSHSCPClient.) |
![]() | ShowHiddenFiles |
Include hidden files in operations that involve listing of directories,
and if supported by the server. Not supported in SFTP.
(Inherited from SSHSCPClient.) |
![]() | SleepEnabled |
Enabling or not of sleeping after a certain number of transfers
|
![]() | SleepTime |
Number of seconds spent asleep
|
![]() | TCPBufferSize |
The size of the TCP read and write buffers. The default value means
the Microsoft defaults are used.
(Inherited from SSHSCPClient.) |
![]() | Timeout |
Overall timeout in milliseconds for waiting for messages and underlying
timeouts on sockets.
(Overrides SSHSCPClientTimeout.) |
![]() | TransferBufferSize |
The size of the buffers (in bytes) used in writing to and reading from the data-sockets.
(Inherited from SSHSCPClient.) |
![]() | TransferNotifyInterval |
The number of bytes transferred between each notification of the
BytesTransferred event.
(Inherited from SSHSCPClient.) |
![]() | TransferNotifyListings |
By default the BytesTransferred event is not triggered during directory
listings - this property can be used to enable this behaviour.
(Inherited from SSHSCPClient.) |
![]() | TransferType | The current file transfer type (BINARY or ASCII). (Overrides SSHSCPClientTransferType.) |
![]() | UMask |
Set and get the umask, the file creation mode mask that
is applied to the default permissions to create the final permission
set.
|
![]() | UserName | User-name of account on the server. (Inherited from SSHSCPClient.) |
![]() | WelcomeMessage |
Server's banner.
(Inherited from SSHSCPClient.) |
![]() | WindowSize |
The SSH window size.
(Inherited from SSHSCPClient.) |
Name | Description | |
---|---|---|
![]() | CancelResume |
Cancel the resume. Use this method if something goes wrong
and the server is left in an inconsistent state. Not used in
SCP as resume is not supported
(Inherited from SSHSCPClient.) |
![]() | CancelTransfer | Cancels the current transfer. (Inherited from SSHSCPClient.) |
![]() | CdUp |
Change the remote working directory to parent
(Overrides SSHSCPClientCdUp.) |
![]() | ChangeGroup | |
![]() | ChangeOwner | |
![]() | ChDir |
Change the remote working directory
(Overrides SSHSCPClientChDir(String).) |
![]() | CheckConnection |
Checks if the client has connected to the server and throws an exception if it hasn't.
This is only intended to be used by subclasses
(Inherited from SSHSCPClient.) |
![]() | CheckTimeout |
Check to see if the timeout has expired
(Inherited from SSHSCPClient.) |
![]() | ChMod |
Changes the access permissions or modes of the specified
file or directory.
|
![]() | CloseSocket | (Inherited from SSHSCPClient.) |
![]() | Connect |
Establish a connection to the SFTP server
(Overrides SSHSCPClientConnect.) |
![]() | CreateSymbolicLink |
Create a symbolic link on the server
|
![]() | Delete | Delete the specified remote file. (Overrides SSHSCPClientDelete(String).) |
![]() | Dir |
List current directory's contents as an array of strings of
filenames.
(Overrides SSHSCPClientDir.) |
![]() | Dir(String) |
List a directory's contents as an array of strings of filenames.
(Overrides SSHSCPClientDir(String).) |
![]() | Dir(String, Boolean) |
List a directory's contents as an array of strings.
(Overrides SSHSCPClientDir(String, Boolean).) |
![]() | DirDetails |
List the current directory's contents as an array of FTPFile objects.
(Overrides SSHSCPClientDirDetails.) |
![]() | DirDetails(String) |
List a directory's contents as an array of FTPFile objects.
(Overrides SSHSCPClientDirDetails(String).) |
![]() | DirDetails(String, FTPFileCallback) | (Overrides SSHSCPClientDirDetails(String, FTPFileCallback).) |
![]() | DirDetails(String, Boolean) |
Returns the given directory's contents and optionally that of its subdirectories
as an array of FTPFile objects.
(Overrides SSHSCPClientDirDetails(String, Boolean).) |
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | ExecuteCommand | (Inherited from SSHSCPClient.) |
![]() | Exists |
Checks for the existence of a file on the server.
(Overrides SSHSCPClientExists(String).) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | Get(String) | Get data from the SFTP server. (Inherited from SSHSCPClient.) |
![]() | Get(Stream, String) |
Get data from the server
(Inherited from SSHSCPClient.) |
![]() | Get(String, String) |
Get data from the SFTP server using the currently
set transfer mode.
(Overrides SSHSCPClientGet(String, String).) |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetLocalCRC |
Get the CRC-32 checksum for the named local file
(Inherited from SSHSCPClient.) |
![]() | GetRemoteCRC |
Get the CRC-32 checksum for the named remote file. Only supported with CompleteFTP.
(Overrides SSHSCPClientGetRemoteCRC(String, Int64, Int32).) |
![]() | GetServerIdentity |
Passes the software identity of the client to the server and returns the software identity of the server
|
![]() | GetSymbolicLinkTarget | |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | MkDir | Create the specified remote working directory. (Overrides SSHSCPClientMkDir(String).) |
![]() | ModTime | Get modification time for a remote file. (Overrides SSHSCPClientModTime(String).) |
![]() | MultipleDelete(FileFilter) |
Delete multiple files in the current remote directory
(Overrides SSHSCPClientMultipleDelete(FileFilter).) |
![]() | MultipleDelete(String) |
Delete multiple files in the current remote directory
(Overrides SSHSCPClientMultipleDelete(String).) |
![]() | MultipleDelete(String, FileFilter, Boolean) |
Delete multiple files in the current remote directory and its subdirectories.
(Overrides SSHSCPClientMultipleDelete(String, FileFilter, Boolean).) |
![]() | MultipleDelete(String, String, Boolean) |
Delete multiple files in the current remote directory and its subdirectories.
(Overrides SSHSCPClientMultipleDelete(String, String, Boolean).) |
![]() | MultipleDeleteDirectories |
Remove a remote directory, and all its files and its subdirectories
(Overrides SSHSCPClientMultipleDeleteDirectories(String).) |
![]() | MultipleGet(String, FileFilter) |
Get multiple files into the specified local directory from the current remote directory
(Overrides SSHSCPClientMultipleGet(String, FileFilter).) |
![]() | MultipleGet(String, String) |
Get multiple files into the specified local directory from the current remote directory
(Overrides SSHSCPClientMultipleGet(String, String).) |
![]() | MultipleGet(String, String, FileFilter, Boolean) |
Get multiple files from the specified remote directory into the specified local directory
(Overrides SSHSCPClientMultipleGet(String, String, FileFilter, Boolean).) |
![]() | MultipleGet(String, String, String, Boolean) |
Get multiple files from the specified remote directory into the specified local directory
(Overrides SSHSCPClientMultipleGet(String, String, String, Boolean).) |
![]() | MultiplePut(String, FileFilter) |
Put multiple files from the specified local directory into the current remote directory
(Overrides SSHSCPClientMultiplePut(String, FileFilter).) |
![]() | MultiplePut(String, String) |
Put multiple files from the specified local directory into the current remote directory
(Overrides SSHSCPClientMultiplePut(String, String).) |
![]() | MultiplePut(String, String, FileFilter, Boolean) |
Put multiple files from the specified local directory into the specified remote directory
(Overrides SSHSCPClientMultiplePut(String, String, FileFilter, Boolean).) |
![]() | MultiplePut(String, String, String, Boolean) |
Put multiple files from the specified local directory into the specified remote directory
(Overrides SSHSCPClientMultiplePut(String, String, String, Boolean).) |
![]() | OnBytesTransferred | (Inherited from SSHSCPClient.) |
![]() | OnCommandSent | (Inherited from SSHSCPClient.) |
![]() | OnReplyReceived | (Inherited from SSHSCPClient.) |
![]() | OnTransferCancelled | (Inherited from SSHSCPClient.) |
![]() | OnTransferCompleteEx | (Inherited from SSHSCPClient.) |
![]() | OnTransferStartedEx | (Inherited from SSHSCPClient.) |
![]() | Put(Byte, String) |
Put data onto the SFTP server in the current directory.
(Overrides SSHSCPClientPut(Byte, String).) |
![]() | Put(Stream, String) |
Put a stream of data onto the FTP server in the current directory.
(Overrides SSHSCPClientPut(Stream, String).) |
![]() | Put(String, String) |
Put a local file onto the SFTP server in the current directory.
(Overrides SSHSCPClientPut(String, String).) |
![]() | Put(Byte, String, Boolean) |
Put data onto the SFTP server in the current directory. Allows
appending if current file exists.
(Overrides SSHSCPClientPut(Byte, String, Boolean).) |
![]() | Put(Stream, String, Boolean) |
Put a stream of data onto the FTP server in the current directory. Allows appending
if current file exists
(Overrides SSHSCPClientPut(Stream, String, Boolean).) |
![]() | Put(String, String, Boolean) |
Upload a local file to the server
(Overrides SSHSCPClientPut(String, String, Boolean).) |
![]() | Pwd |
Get the current remote working directory
(Overrides SSHSCPClientPwd.) |
![]() | Quit |
Quit the session
(Overrides SSHSCPClientQuit.) |
![]() | QuitImmediately |
Quit the session immediately. Just close the socket. Don't send
any messages to the server.
(Overrides SSHSCPClientQuitImmediately.) |
![]() | Rename |
Rename a remote file
(Overrides SSHSCPClientRename(String, String).) |
![]() | Resume | Make the next file transfer (put or get) resume. (Overrides SSHSCPClientResume.) |
![]() | ResumeDownload | Make the next download resume at a specific point. (Overrides SSHSCPClientResumeDownload(Int64).) |
![]() | RmDir |
Remove a directory
(Overrides SSHSCPClientRmDir(String).) |
![]() | SetModTime | Set modification time for a remote file. (Overrides SSHSCPClientSetModTime(String, DateTime).) |
![]() | Size |
Get the size of a remote file.
(Overrides SSHSCPClientSize(String).) |
![]() | TestConnection |
Tests the connection
(Overrides SSHSCPClientTestConnection.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | Unlock |
Unlock the software for use. This method should be used when
a configuration file isn't available
(Inherited from SSHSCPClient.) |
Name | Description | |
---|---|---|
![]() | BytesTransferred |
Event triggered every time TransferNotifyInterval bytes transferred.
(Inherited from SSHSCPClient.) |
![]() | CommandSent |
Triggered every time a command is sent to the server.
(Inherited from SSHSCPClient.) |
![]() | ReplyReceived |
Triggered every time a logical reply is received from the server. In SFTP this will NOT
be triggered for every packet that arrives.
(Inherited from SSHSCPClient.) |
![]() | TransferCancelled |
Notifies of the cancellation of a transfer
(Inherited from SSHSCPClient.) |
![]() | TransferCompleteEx |
Notifies of the completion of a transfer
(Inherited from SSHSCPClient.) |
![]() | TransferStartedEx |
Notifies of the start of a transfer
(Inherited from SSHSCPClient.) |
![]() | ValidatingServer |
Notifies that the server must be validated
(Inherited from SSHSCPClient.) |
Name | Description | |
---|---|---|
![]() | _proxySettings |
Proxy settings
(Inherited from SSHSCPClient.) |
![]() | cancelTransfer | Can be used to cancel a transfer (Inherited from SSHSCPClient.) |
![]() | closeStreamsAfterTransfer |
If true then streams are closed after a transfer has completed.
(Inherited from SSHSCPClient.) |
![]() | compatFlags |
Configuration flags for non-compliant servers
(Inherited from SSHSCPClient.) |
![]() | compressionAlg |
Compression algorithms
(Inherited from SSHSCPClient.) |
![]() | controlPort | (Inherited from SSHSCPClient.) |
![]() | cwd |
Current remote working directory
(Inherited from SSHSCPClient.) |
![]() ![]() | DEFAULT_PERMISSIONS |
Default value of umask.
|
![]() ![]() | DEFAULT_UMASK |
Default value of umask.
|
![]() | deleteOnFailure | If a download to a file fails, delete the partial file (Inherited from SSHSCPClient.) |
![]() | detectTransferMode |
Do we detect transfer mode when transferring files?
(Inherited from SSHSCPClient.) |
![]() | key |
License key
(Inherited from SSHSCPClient.) |
![]() | knownHostsManager | Manages the list of known hosts (Inherited from SSHSCPClient.) |
![]() | lastBytesTransferred |
Holds the number of bytes transferred in that most recent transfer.
(Inherited from SSHSCPClient.) |
![]() | lastFileTransferred |
Name of the last file transferred.
(Inherited from SSHSCPClient.) |
![]() | logTag | Logging tag (Inherited from SSHSCPClient.) |
![]() | monitorInterval | Bytes transferred in between monitor callbacks (Inherited from SSHSCPClient.) |
![]() | owner |
License owner
(Inherited from SSHSCPClient.) |
![]() | prompts |
List of authorization prompts
(Inherited from SSHSCPClient.) |
![]() | remoteHost |
Remote host we are connecting to
(Inherited from SSHSCPClient.) |
![]() | remoteIPAddress |
IP address of remote host in string form
(Inherited from SSHSCPClient.) |
![]() | resume | If true, a file transfer is being resumed (Inherited from SSHSCPClient.) |
![]() | serverValidation | Determines how the remote host is validated (Inherited from SSHSCPClient.) |
![]() | socket | (Inherited from SSHSCPClient.) |
![]() | socks |
SOCKS settings
(Inherited from SSHSCPClient.) |
![]() | tcpBufferSize |
The TCP read and write buffer sizes
(Inherited from SSHSCPClient.) |
![]() | throttler |
Threshold for throttling
(Inherited from SSHSCPClient.) |
![]() | timeout | Timeout in milliseconds
(Inherited from SSHSCPClient.) |
![]() | transferBufferSize | Size of transfer buffers (Inherited from SSHSCPClient.) |
![]() | transferNotifyListings | Should BytesTransferred event be triggered in directory listings? (Inherited from SSHSCPClient.) |
![]() | transferType | Record of the transfer type - make the default BINARY (Inherited from SSHSCPClient.) |
SSHFTPClient supports SOCKS (4, 4A, and 5) and SFTP.
SSHFTPClient supports SFTP, which stands for SSH File Transfer Protocol. Essentially, it is file transfer over an SSH connection, hence it has the security of SSH. SFTP is only superficially related to FTP and FTPS. It achieves the same goals of file transfer and related operations, but the underlying protocol is entirely different.
// create an SFTP client SSHFTPClient ftp = new SSHFTPClient(); ftp.RemoteHost = "192.168.10.123"; // Turn off server validation (ONLY do this when testing) ftp.ServerValidation = SecureFTPServerValidationType.None; // set up the credentials for password authentication (the default) ftp.UserName = "myuser"; ftp.Password = "mypassword"; // connect to the server ftp.Connect(); // get a file ftp.Get("file.txt", "file.txt"); // close the connection ftp.Quit();
This example uses password authentication and does not attempt to verify the server (which should always be done in production systems).
Server Validation: The examples above used no server validation. This is only normally acceptable only when testing. To be secure applications should always validate the server that they're communicating with. If the [!:ServerValidation] property is set to SecureFTPServerValidationType.Automatic or SecureFTPServerValidationType.AutomaticIgnoreHostName then SSHFTPClient will attempt to validate the server's public key upon connection.
Public keys are managed by the KnownHostsManager, available in the [!:KnownHosts] property. There are two ways that the client can load server public keys - via the known_hosts file or by explicitly loading a public key from a file.
Client Validation: Client authentication can be either by password, by public/private keys, or by keyboard- interactive authentication. The default is password authentication. The current authentication method can be found (and set) from the [!:AuthenticationMethod] property.
Server Compatibility: Generally, this class should work with most SFTP servers. Some servers return an error saying the file does not exist after creating it. By default, the client does a permission change after creating the file, which is done to ensure the file permissions are correct. If this error is encountered, try setting the [!:ServerCompatibility] property to SSHDisableChmodAfterPut to try to eliminate the problem.
Public key algorithms: Either DSA or RSA or both can be set for the preferred public key algorithms for server authentication. If, for example, RSA is set, the server will present an RSA public key to the client (if the server supports RSA keys of course - some servers do not). The [!:PreferredHostKeyAlgorithms] property is a bitwise flag and can be set to combinations of the SSHPublicKeyAlgorithm enum values by OR'ing them together. The default is all algorithms enabled.
Cipher algorithms: The cipher algorithms are the symmetric algorithms used to perform the encryption of the SFTP data and commands. The [!:PreferredCipherAlgorithms] property is a bitwise flag and can be set to combinations of the SSHCipherAlgorithm enum values by OR'ing them together. The default is all algorithms enabled.
SOCKS: SOCKS may be used for FTPing through firewalls. For this to be possible a SOCKS proxy must be available, and a user account must be set up on that proxy. SSLFTPClient supports all the popular versions of SOCKS - 4, 4A, and 5.
The SOCKS features are controlled entirely through the SocksContext property. If it is null (the default) then SOCKS is not used. To use SOCKS, the property must be set to an instance of Socks4Context or Socks5Context. For example, for SOCKS4:
myFTPClient.SocksContext = new Socks4Context("192.168.0.2", 1080, "marvin23");
Socks5Context socksContext = new Socks5Context("192.168.0.2", 1080); socksContext.AuthMethods.Add(new Socks5NoAuthMethod()); socksContext.AuthMethods.Add(new Socks5UserNamePasswordAuthMethod("marvin23", "m31erk")); myFTPClient.SocksContext = socksContext;