Library libssh2-utility
Utility functions for libssh2.
Provides helper class for the libssh2 binding that abstracts away details of running remote commands.
Copyright © Same as Nmap--See https://nmap.org/book/man-legal.html
Source: https://svn.nmap.org/nmap/nselib/libssh2-utility.lua
Functions
- SSHConnection:connect (host, port)
Sets up a connection with a server.
- SSHConnection:connect_pcall (host, port)
Sets up a connection with a server. Call performed with pcall.
- SSHConnection:disconnect ()
Closes connection.
- SSHConnection:list (username)
Attempt to retrieve a list of supported authentication methods
- SSHConnection:new ()
Returns a new connection object.
- SSHConnection:password_auth (username, password)
Attempts to authenticate using provided credentials.
- SSHConnection:publickey_auth (username, privatekey_file, passphrase)
Attempts to authenticate using provided private key.
- SSHConnection:publickey_canauth (username, key)
Attempts authentication with public key
- SSHConnection:read_publickey (publickey)
Attempts to read public key file
- SSHConnection:run_remote (cmd)
Runs a shell command on the remote host.
- SSHConnection:set_timeout (ssh_timeout)
Sends ssh timeout
Functions
- SSHConnection:connect (host, port)
-
Sets up a connection with a server.
Parameters
- host
- A host to connect to.
- port
- A port to connect to.
Return value:
true on success or nil on failure - SSHConnection:connect_pcall (host, port)
-
Sets up a connection with a server. Call performed with pcall.
Parameters
- host
- A host to connect to.
- port
- A port to connect to.
Return values:
- true on success or error message on failure
- error code if error was triggered
- SSHConnection:disconnect ()
-
Closes connection.
- SSHConnection:list (username)
-
Attempt to retrieve a list of supported authentication methods
Parameters
- username
- A username to authenticate as.
Return value:
A list with the authentication methods on success or false on failure. - SSHConnection:new ()
-
Returns a new connection object.
Return value:
A connection object. - SSHConnection:password_auth (username, password)
-
Attempts to authenticate using provided credentials.
Parameters
- username
- A username to authenticate as.
- password
- A password to authenticate as.
Return value:
true on success or false on failure. - SSHConnection:publickey_auth (username, privatekey_file, passphrase)
-
Attempts to authenticate using provided private key.
Parameters
- username
- A username to authenticate as.
- privatekey_file
- A path to a privatekey.
- passphrase
- A passphrase for the privatekey.
Return value:
true on success or false on failure. - SSHConnection:publickey_canauth (username, key)
-
Attempts authentication with public key
Parameters
- username
- A username to authenticate as.
- key
- Base64 decrypted public key.
Return values:
- true if the public key can be used to authenticate as the user, false otherwise
- Error message if an error occurs.
- SSHConnection:read_publickey (publickey)
-
Attempts to read public key file
Parameters
- publickey
- An SSH public key file.
Return values:
- true on success or false on error.
- public key data on success or error code on error.
- SSHConnection:run_remote (cmd)
-
Runs a shell command on the remote host.
Parameters
- cmd
- A command to run.
Return value:
The command output. - SSHConnection:set_timeout (ssh_timeout)
-
Sends ssh timeout
Parameters
- ssh_timeout
- Time in miliseconds before considering the situation an error.