LibsshWrapper class

high-level wrapper on top of libssh binding - The SSH library! libssh is a multiplatform C library implementing the SSHv2 protocol on client and server side. With libssh, you can remotely execute programs, transfer files, use a secure and transparent tunnel https://www.libssh.org/

Constructors

LibsshWrapper(String host, {String? username, String? password, int port = 22, bool defaultDllPath = true, DynamicLibrary? inDll, String ddlname = 'ssh.dll', bool verbosity = false})
if defaultDllPath == true get ddl from default sytem folder Exemple: in windows c:\windows\Sytem32 else get dll from Directory.current.path
LibsshWrapper.fromOptions(LibssOptions options)

Properties

hashCode int
The hash code for this object.
no setterinherited
host String
getter/setter pair
isConnected bool
getter/setter pair
libsshBinding LibsshBinding
getter/setter pair
mySshSession ssh_session
getter/setter pair
password String?
getter/setter pair
port int
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
username String?
getter/setter pair
verbosity bool
getter/setter pair

Methods

connect() → void
Connect to SSH server
disconnect() → void
disconnect from server
dispose() → void
free memory
execCommandsInShell(List<String> commands) List<String>
experimental as it may not be able to detect the prompt execute commands in the interactive shell the order of execution is based on the order of the command list and return a list with the response of each command in the order of execution
execCommandSync(String command, {Allocator allocator = calloc}) String
execute only one command to execute several commands start a scripting language example: execCommandSync(session,"cd /tmp; mkdir mytest; cd mytest; touch mytest");
getSizeOfDirectory(String remoteDirectoryPath, {bool isThrowException = true}) int
return total size in bytes of each file inside folder ignoring linux directory metadata size
getSizeOfFile(String remoteFilePath, {bool isThrowException = true}) int
return total size in bytes of file , work on GNU/Linux systems, tested in debian 10 based on https://unix.stackexchange.com/questions/16640/how-can-i-get-the-size-of-a-file-in-a-bash-script/185039#185039
getSizeOfFileSystemItem(DirectoryItem item, {bool isThrowException = true}) int
return total size in bytes of file or directory , work on GNU/Linux systems, tested in debian 10
initSsh() ssh_session
initialize ssh - Open the session and set the options
isReady() → void
check if session started and connection is open
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
scpDownloadDirectory(String remoteDirectoryPath, String fullLocalDirectoryPathTarget, {Allocator allocator = calloc, void callbackStats(int totalBytes, int loaded, int currentFileSize, int countDirectory, int countFiles)?, void printLog(Object? obj)?, bool cancelCallback()?, bool isThrowException = false, bool updateStatsOnFileEnd = true, bool dontStopIfFileException = false}) Future<void>
fullLocalDirectoryPathTarget example c:\downloads remoteDirectoryPath example /var/www this function work only if remote is linux debian like sytem
scpDownloadFileTo(String fullRemotePathSource, String fullLocalPathTarget, {void callbackStats(int, int)?, bool recursive = true, bool cancelCallback()?, bool dontStopIfFileException = false}) Future<void>
downloads a file from an SFTP/SCP server
sftpDownloadFileTo(String fullRemotePath, String fullLocalPath, {Pointer<sftp_session_struct>? inSftp, Allocator allocator = calloc, bool recursive = true}) Future<void>
download one file via SFTP of remote server
sftpDownloadFileToFromRawPath(Uint8List fullRemotePath, String fullLocalPath, {Pointer<sftp_session_struct>? inSftp, Allocator allocator = calloc}) Future<void>
sftpListDir(String fullRemotePath, {Allocator allocator = calloc, bool allowMalformed = false}) List<DirectoryItem>
Listing the contents of a directory fullRemotePath one String fullRemotePath allowMalformed allow Malformed utf8 file and directory name
sftpListDirFromRawPath(List<int> fullRemotePath, {Allocator allocator = calloc, bool allowMalformed = false}) List<DirectoryItem>
Listing the contents of a directory fullRemotePath one Uint8List fullRemotePath allowMalformed allow Malformed utf8 file and directory name
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited