IPWorks SSH 2020 Python Edition

Questions / Feedback?

SSHDaemon Class

Properties   Methods   Events   Configuration Settings   Errors  

The SSHDaemon class is used to create Secure Shell (SSH) servers. The class handles multiple simultaneous connections on the same TCP/IP port (service port). It is designed to balance the load between connections for a fast, powerful server.

Syntax

class ipworksssh.SSHDaemon

Remarks

The SSHDaemon class is the SSH-enabled equivalent of the IPWorks IPDaemon class, extended by a set of new properties and events that deal with SSH security. The ssh_compression_algorithms and ssh_encryption_algorithms properties determine which protocols are enabled for the SSH handshake. The ssh_cert* properties are used to select a certificate for the server (please note that a valid certificate MUST be selected before the server can function). The on_ssh_user_auth_request event will allow you to use authenticate clients using digital certificates or passwords. Finally, the on_ssh_status event provides information about the SSH handshake and underlying protocol notifications.

By default, each instance of SSHDaemon can handle up to 1000 simultaneous incoming connections (this number may be increased up to 100,000, or decreased to a lower value by using the MaxConnections configuration setting).

SSH connections are identified by a ConnectionId. Events relating to these connections as a whole will use the ConnectionId to identify the specific connection. Connections may also contained one or more multiplexed channels, which are identified by a ChannelId. Channel-level events will specify the ChannelId to which they relate.

SSHDaemon can start to listen on a port by setting the listening property to True. When a remote host asks for a connection, the on_connection_request event is fired. At that point, the connection can either be accepted or rejected. If the connection is accepted, a ConnectionId is assigned, and communication can start. From this point on, the operation is very similar to SSHClient. Data can be sent to an individual SSHChannel using send_channel_data. The address and port of the incoming connection can be found by querying the client_remote_host and client_remote_port properties.

Note: Server components are designed to process events as they occur. To ensure events are processed in a timely manner do_events should be called in a loop after the server is started.

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

ssh_channel_countThe number of records in the arrays.
bytes_sentThe number of bytes actually sent after a sending channel data.
channel_idAn id generated by the class to identify the current SSH channel.
data_to_sendA string of data to be sent to the remote host.
ready_to_sendThis property is True when data can be sent over the SSH Channel.
record_lengthThe length of received data records.
serviceThis property holds the channel type that was requested when opening the channel.
connection_backlogThe maximum number of pending connections maintained by the TCP/IP subsystem.
ssh_connection_countThe number of records in the SSHConnection arrays.
ssh_connection_connectedUsed to disconnect individual connections and/or show their status.
ssh_connection_local_addressThis property shows the IP address of the interface through which the connection is passing.
ssh_connection_remote_hostThe RemoteHost shows the IP address of the remote host through which the connection is coming.
ssh_connection_remote_portThe RemotePort shows the TCP port on the remote host through which the connection is coming.
ssh_connection_timeoutA timeout for the class.
default_auth_methodsSpecifies the supported authentication methods.
default_timeoutAn initial timeout value to be used by incoming connections.
keyboard_interactive_messageThe instructions to send to the client during keyboard-interactive authentication.
keyboard_interactive_prompt_countThe number of records in the KeyboardInteractivePrompt arrays.
keyboard_interactive_prompt_echoSpecifies if the client should echo the value entered by the user or not.
keyboard_interactive_prompt_promptThe prompt label/text the client should present to the user.
listeningIf True, the class accepts incoming connections on LocalPort.
local_hostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
local_portThe TCP port in the local host where the class listens.
ssh_cert_encodedThe certificate (PEM/base64 encoded).
ssh_cert_storeThe name of the certificate store for the client certificate.
ssh_cert_store_passwordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
ssh_cert_store_typeThe type of certificate store for this certificate.
ssh_cert_subjectThe subject of the certificate used for client authentication.
ssh_compression_algorithmsA comma-separated list containing all allowable compression algorithms.
ssh_encryption_algorithmsA comma-separated list containing all allowable encryption algorithms.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

close_channelCloses a existing SSHChannel .
configSets or retrieves a configuration setting.
disconnectDisconnect the specified client.
do_eventsProcesses events from the internal message queue.
exchange_keysCauses the class to exchange a new set of session keys on the specified connection.
get_ssh_paramUsed to read a field from an SSH packet's payload.
get_ssh_param_bytesUsed to read a field from an SSH packet's payload.
open_channelOpens a new SSHChannel .
resetReset the class.
send_channel_dataUsed to send regular data over an SSH channel.
send_ssh_packetUsed to send an encoded SSH packet to the server.
set_ssh_paramUsed to write a field to the end of a payload.
shutdownShuts down the server.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

on_connectedFired immediately after a connection completes (or fails).
on_connection_requestFired when a request for connection comes from a remote host.
on_disconnectedFired when a connection is closed.
on_errorInformation about errors during data delivery.
on_logFires once for each log message.
on_ssh_channel_closedFired when a channel is closed.
on_ssh_channel_data_inFired when data is received on an SSH channel.
on_ssh_channel_eofFired when the remote peer signals the end of the data stream for the channel.
on_ssh_channel_openedFired when a channel is successfully opened.
on_ssh_channel_open_requestFired when a client attempts to open a new channel.
on_ssh_channel_ready_to_sendFired when the class is ready to send data.
on_ssh_channel_requestFired when the SSHHost sends a channel request to the client.
on_ssh_channel_requestedFired if the SSHChannelRequest was successful, any further processing for the channel request should be done here.
on_ssh_service_requestFired when a client requests a service to be started.
on_ssh_statusShows the progress of the secure connection.
on_ssh_user_auth_requestFires when a client attempts to authenticate a connection.

Configuration Settings


The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.

AltSSHCertCountThe number of records in the AltSSHCert configuration settings.
AltSSHCertStore[i]The name of the certificate store.
AltSSHCertStorePassword[i]The password used to open the certificate store.
AltSSHCertStoreType[i]The type of certificate store.
AltSSHCertSubject[i]The alternative certificate subject.
ClientSSHVersionString[ConnectionId]The client's version string.
DefaultIdleTimeoutSpecifies the default idle timeout for inactive clients.
KeyboardInteractivePrompts[ConnectionId]Specifies custom keyboard-interactive prompts for particular connections.
KeyRenegotiationThresholdSets the threshold for the SSH Key Renegotiation.
LogLevelSpecifies the level of detail that is logged.
MaxAuthAttemptsThe maximum authentication attempts allowed before forcing a disconnect.
ServerSSHVersionStringThe SSH version string sent to connecting clients.
SSHKeepAliveCountMaxThe maximum number of keep alive packets to send without a response.
SSHKeepAliveIntervalThe interval between keep alive packets.
SSHKeyExchangeAlgorithmsSpecifies the supported key exchange algorithms.
SSHMacAlgorithmsSpecifies the supported Mac algorithms.
SSHPubKeyAuthSigAlgorithmsSpecifies the allowed signature algorithms used by a client performing public key authentication.
SSHPublicKeyAlgorithmsSpecifies the supported public key algorithms.
SSHVersionPatternThe pattern used to match the remote host's version string.
UserAuthBanner[ConnectionId]A custom user authentication banner.
AllowedClientsA comma-separated list of host names or IP addresses that can access the class.
BindExclusivelyWhether or not the class considers a local port reserved for exclusive use.
ConnectionUIDThe unique connectionId for a connection.
DefaultConnectionTimeoutThe inactivity timeout applied to the SSL handshake.
InBufferSizeThe size in bytes of the incoming queue of the socket.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
KeepAliveRetryCountThe number of keep-alive packets to be sent before the remotehost is considered disconnected.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
MaxConnectionsThe maximum number of connections available.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.
TcpNoDelayWhether or not to delay when sending packets.
UseIOCPWhether to use the completion port I/O model.
UseIPv6Whether to use IPv6.
UseWindowsMessagesWhether to use the WSAAsyncSelect I/O model.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseInternalSecurityAPITells the class whether or not to use the system security libraries or an internal implementation.

Copyright (c) 2023 /n software inc. - All rights reserved.
IPWorks SSH 2020 Python Edition - Version 20.0 [Build 8501]