Skip to content

SSH.SFTPSession

Andrew Lambert edited this page Nov 26, 2022 · 21 revisions

SSH.SFTPSession

Class Declaration

 Protected Class SFTPSession

Remarks

This class represents a SSH File Transfer Protocol (SFTP) session. A single SFTPSession can perform multiple simultaneous file operations.

File paths

When giving a file or directory name you can specify either an absolute path (i.e. the first character is /) or a path which is relative to the current WorkingDirectory (no leading /). Paths containing .. and . are not supported.

The WorkingDirectory will be initialized to /home/username/ if such a directory actually exists. Otherwise the WorkingDirectory will point to the root directory of the server (/). If you intend to use relative paths then it behooves you to verify that the WorkingDirectory is what you expect it to be.

Methods

Properties

Example

This example opens an SFTP session and then creates a directory listing, a download, and an upload over it.

  Dim session As SSH.Session = SSH.Connect("ssh.example.com", 22, "username", "password")
  Dim sftp As New SSH.SFTPSession(session)
  Dim listing As SSH.SFTPDirectory = sftp.ListDirectory("/home/bob/desktop/")
  Dim download As SSH.SFTPStream = sftp.Get("/home/bob/desktop/file.txt")
  Dim upload As SSH.SFTPStream = sftp.Put("/home/bob/desktop/file2.txt")

See also

Clone this wiki locally