Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

SSH2SessionMBS.Banner as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Get the remote banner.
Notes: Once the session has been setup and Handshake has completed successfully, this function can be used to get the server id from the banner each server presents.

Feedback, Comments & Corrections

SSH2SessionMBS.Constructor(IP as string, Port as Integer = 22, TimeOut as Integer = 30)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: The constructor for using a new socket.
Notes:
The plugin creates a new socket, connects to the given IP&Port and than creates a new session for it.
Lasterror is set.
Please check if Handle property is non zero after constructor finishes.

Timeout defines timeout for connection in seconds. While waiting, the plugin yields time to other threads.
If timeout is zero, the connection will not yield and take up to the default TCP/IP timeout.

IPv4, IPv6 address or domain name with version 18.3 or newer.

See also:

Feedback, Comments & Corrections

SSH2SessionMBS.Constructor(socket as TCPSocket)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: The constructor for using an existing socket.
Notes:
Initializes a new session.
socket: The socket to use. The plugin keeps reference to this socket in socket property.

You can use a Xojo socket and connect it. Once connected, pass it here, so the session can use this socket for communication.
If you connect the xojo socket in a loop on a thread, be sure to call poll method of socket, so it processes events like connecting. In main thread with timer, you would get this automatically.

See also:

Feedback, Comments & Corrections

SSH2SessionMBS.Constructor(socketHandle as Integer, CloseSocketLater as boolean = false)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: The constructor for using an existing socket.
Notes:
Initializes a new session.
socketHandle: The socket to use. Can be TCPSocket's handle property for a Xojo socket. Or a socket connected via declares.
You can put the socket in the socket property to keep it alive as long as session is in memory.

Set CloseSocketLater = true if you pass a socket which can be closed in destructor. For Xojo socket, pass false as Xojo closes socket later.
You can use a Xojo socket and connect it. Once connected, pass it here, so the session can use this socket for communication.

See also:

Feedback, Comments & Corrections

SSH2SessionMBS.Destructor
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: The destructor.

Feedback, Comments & Corrections

SSH2SessionMBS.Disconnect(description as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Terminate transport layer.
Notes:
Lasterror is set.
description: Human readable reason for disconnection.

See also:

Feedback, Comments & Corrections

SSH2SessionMBS.Disconnect(reason as Integer, description as string, lang as string = "")
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Terminate transport layer.
Notes:
Lasterror is set.

reason: One of the Disconnect Reason constants.
description: Human readable reason for disconnection.
lang: Localization string describing the langauge/encoding of the description provided.

See also:

Feedback, Comments & Corrections

SSH2SessionMBS.HostKey(byref Type as Integer) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Get the remote key.

Feedback, Comments & Corrections

SSH2SessionMBS.HostKeyHash(HashType as Integer) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Return a hash of the remote host's key.
Notes:
HashType: kHostKeyHashSHA1 or kHostKeyHashMD5.
Returns the computed digest of the remote system's hostkey. The length of the returned string is hash_type specific (e.g. 16 bytes for MD5, 20 bytes for SHA1).
Computed hostkey hash value, or empty string if the information is not available (either the session has not yet been started up, or the requested hash algorithm was not available). The hash consists of raw binary bytes, not hex digits, so it is not directly printable.

Feedback, Comments & Corrections

SSH2SessionMBS.OpenDirectTCPIPChannel(host as string, port as integer, sourceHost as string = "127.0.0.1", sourcePort as Integer = 22) as SSH2ChannelMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 18.3 Yes Yes Yes Yes No
Function: Tunnel a TCP connection through an SSH session.
Notes:
host: Third party host to connect to using the SSH host as a proxy.
port: Port on third party host to connect to.
SourceHost: Host to tell the SSH server the connection originated on.
SourcePort: Port to tell the SSH server the connection originated from.

Tunnel a TCP/IP connection through the SSH transport via the remote host to a third party. Communication from the client to the SSH server remains encrypted, communication from the server to the 3rd party host travels in cleartext.

This is not a replacement for ssh in command line with -L option.

Returns a newly allocated channel object, or nil on errors.

Feedback, Comments & Corrections

SSH2SessionMBS.OpenSession as SSH2ChannelMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Establish a generic session channel.
Notes:
Lasterror is set.
Returns nil if the session start fails.

Feedback, Comments & Corrections

SSH2SessionMBS.SessionFlag(Flag as Integer, Value as boolean)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Get/Set a session flag.
Notes:
See kFlag* constants.
Lasterror is set.

Feedback, Comments & Corrections

SSH2SessionMBS.SessionHandshake
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Perform the SSH handshake.
Notes: Lasterror is set.

Feedback, Comments & Corrections

SSH2SessionMBS.SetBanner(Banner as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Set the SSH prococol banner for the local client.
Notes:
Set the banner that will be sent to the remote host when the SSH session is started with Handshake. This is optional; a banner corresponding to the protocol and libssh2 version will be sent by default.
Lasterror is set.

Feedback, Comments & Corrections

SSH2SessionMBS.SetMethodPreference(methodType as Integer, Pref as string) as Boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 18.5 Yes Yes Yes Yes No
Function: Set preferred key exchange method.
Example:
// set preferences for key exchange method:
dim r as Boolean = s.SetMethodPreference(SSH2SessionMBS.kMethodKEX, "diffie-hellman-group-exchange-sha256")
Notes:
methodType: One of the Method Type constants.
Pref: Coma delimited list of preferred methods to use with the most preferred listed first and the least preferred listed last. If a method is listed which is not supported by libssh2 it will be ignored and not sent to the remote host during protocol negotiation.

Set preferred methods to be negotiated. These preferences must be set prior to calling SessionHandshake, as they are used during the protocol initiation phase.

Return true on success or false on failure. Lasterror is set. Lasterror is set to LIBSSH2_ERROR_EAGAIN (-37) when it would otherwise block. While LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.

Feedback, Comments & Corrections

SSH2SessionMBS.SupportedAlgorithms(methodType as Integer) as String()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 18.5 Yes Yes Yes Yes No
Function: Get list of supported algorithms.
Example:
dim s as new SSH2SessionMBS("localhost")

dim KeyExchange() as string = s.SupportedAlgorithms(SSH2SessionMBS.kMethodKEX)
dim HostKey() as string = s.SupportedAlgorithms(SSH2SessionMBS.kMethodHostKey)
dim CryptCS() as string = s.SupportedAlgorithms(SSH2SessionMBS.kMethodCryptCS)
dim CryptSC() as string = s.SupportedAlgorithms(SSH2SessionMBS.kMethodCryptSC)
dim MacCS() as string = s.SupportedAlgorithms(SSH2SessionMBS.kMethodMacCS)
dim MacSC() as string = s.SupportedAlgorithms(SSH2SessionMBS.kMethodMacSC)
dim CompCS() as string = s.SupportedAlgorithms(SSH2SessionMBS.kMethodCompCS)
dim CompSC() as string = s.SupportedAlgorithms(SSH2SessionMBS.kMethodCompSC)
dim LangCS() as string = s.SupportedAlgorithms(SSH2SessionMBS.kMethodLangCS)
dim LangSC() as string = s.SupportedAlgorithms(SSH2SessionMBS.kMethodLangSC)

Break
Notes:
Method type: see kMethod* constants.

Get a list of supported algorithms for the given methodType. The methodType parameter is equivalent to methodType in SetMethodPreference.

In order to get a list of all supported compression algorithms, SessionFlag(SSH2SessionMBS.kFlagCompress, true) must be called before calling this function, otherwise only "none" will be returned.

On success, returns array with algorithms
Lasterror is set with error code.

Feedback, Comments & Corrections

SSH2SessionMBS.UserAuthKeyboardInteractive(UserName as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Authenticate a session using keyboard-interactive authentication.
Notes:
username: Name of user to attempt keyboard-interactive authentication for.
Lasterror is set.
Calls KeyboardCallback callback to query input from user.

Feedback, Comments & Corrections

SSH2SessionMBS.UserAuthList(username as string) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: List supported authentication methods.
Notes:
username: Username which will be used while authenticating. Note that most server implementations do not permit attempting authentication with different usernames between requests. Therefore this must be the same username you will use on later userauth calls.

Send a SSH_USERAUTH_NONE request to the remote host. Unless the remote host is configured to accept none as a viable authentication scheme (unlikely), it will return SSH_USERAUTH_FAILURE along with a listing of what authentication schemes it does support. In the unlikely event that none authentication succeeds, this method with return NULL. This case may be distinguished from a failing case by examining Authenticated.

Feedback, Comments & Corrections

SSH2SessionMBS.UserAuthPassword(UserName as string, Password as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Authenticate a session with username and password.
Notes:
username: Name of user to attempt plain password authentication for.
password: Password to use for authenticating username.

Attempt basic password authentication. Note that many SSH servers which appear to support ordinary password authentication actually have it disabled and use Keyboard Interactive authentication (routed via PAM or another authentication backed) instead.
Lasterror is set.

Feedback, Comments & Corrections

SSH2SessionMBS.UserAuthPublicKeyFromFile(UserName as string, publickey as folderitem, privatekey as folderitem, Passphrase as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Authenticate a session with a public key, read from a file.
Notes:
Lasterror is set.
username: user name to authenticate as.
publickey: Path of the public key file. (e.g. /etc/ssh/hostkey.pub). If libssh2 is built against OpenSSL, this option can be set to ""/nil.
privatekey: Path of the private key file. (e.g. /etc/ssh/hostkey)
passphrase: Passphrase to use when decoding privatekey.

Attempt public key authentication using a PEM encoded private key file stored on disk

See also:

Feedback, Comments & Corrections

SSH2SessionMBS.UserAuthPublicKeyFromFile(UserName as string, publickey as string, privatekey as string, Passphrase as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Authenticate a session with a public key, read from a file.
Notes:
Lasterror is set.
username: user name to authenticate as.
publickey: Path of the public key file. (e.g. /etc/ssh/hostkey.pub). If libssh2 is built against OpenSSL, this option can be set to ""/nil.
privatekey: Path of the private key file. (e.g. /etc/ssh/hostkey)
passphrase: Passphrase to use when decoding privatekey.

Attempt public key authentication using a PEM encoded private key file stored on disk

See also:

Feedback, Comments & Corrections

SSH2SessionMBS.UserAuthPublicKeyFromMemory(UserName as string, publickey as string, privatekey as string, Passphrase as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 16.3 Yes Yes Yes Yes No
Function: Authenticate a session with a public key, read from memory
Notes:
This function allows to authenticate a session with a public key read from memory.
Lasterror is set.

username - Remote user name to authenticate as.
publickeydata - Buffer containing the contents of a public key file. Optional.
privatekeydata - Buffer containing the contents of a private key file.
passphrase - Passphrase to use when decoding private key file.

Keys must have LF as line ending, not CR.

Attempt public key authentication using a PEM encoded private key file stored in memory.

Feedback, Comments & Corrections

SSH2SessionMBS.WaitSocket
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Network MBS Network Plugin 14.0 Yes Yes Yes Yes No
Function: Waits on the socket for sending or receiving.

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Network Plugin.




Links
MBS Xojo tutorial videos