Class AMNetSshServer
Main .NET-facing SSH server wrapper used to host SFTP and SCP services.
Implements
Inherited Members
Namespace: ApacheMinaSSHD.NET.Wrapper
Assembly: ApacheMinaSSHD.NET.Wrapper.dll
Syntax
public sealed class AMNetSshServer : IDisposable
Remarks
This type hides the underlying Apache MINA SSHD server from application code. Configure authentication, host keys, filesystem policy, and enabled subsystems before calling Start().
Properties
| Edit this page View SourceConfig
Gets server configuration helpers for resource limits, timeouts, and cryptographic algorithms.
Declaration
public AMNetSshServerConfig Config { get; }
Property Value
| Type | Description |
|---|---|
| AMNetSshServerConfig |
Host
Gets or sets the bind address. Use null to use the server default.
Accepts IPv4, IPv6, or valid hostname. Rejects empty/whitespace-only values.
Declaration
public string? Host { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Port
Gets or sets the TCP port the SSH server listens on.
Declaration
public int Port { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceDispose()
Stops the server if it was started.
Declaration
public void Dispose()
GetConfiguredAuthenticationMethods()
Gets the configured authentication method chains in evaluation order.
Declaration
public IReadOnlyList<IReadOnlyList<string>> GetConfiguredAuthenticationMethods()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<IReadOnlyList<string>> |
IsClosed()
Returns whether the server has been closed.
Declaration
public bool IsClosed()
Returns
| Type | Description |
|---|---|
| bool |
IsStarted()
Returns whether the server has been started.
Declaration
public bool IsStarted()
Returns
| Type | Description |
|---|---|
| bool |
SetAuthenticationMethodGroups(params IEnumerable<string>[])
Sets the authentication method policy using one or more required method groups.
Declaration
public void SetAuthenticationMethodGroups(params IEnumerable<string>[] authenticationMethodGroups)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<string>[] | authenticationMethodGroups | Each group contains methods that must all succeed in order. The outer set represents alternative groups. |
SetAuthenticationMethods(params string[])
Sets the authentication method policy using one or more pre-built method chains.
Declaration
public void SetAuthenticationMethods(params string[] authenticationChains)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | authenticationChains | Authentication chains such as PublicKey or values returned by RequireAll(params string[]). |
SetAuthorizedKeysAuthenticator(IAMNetAuthorizedKeysAuthenticator)
Enables public key authentication backed by an authorized_keys file.
Declaration
public void SetAuthorizedKeysAuthenticator(IAMNetAuthorizedKeysAuthenticator authorizedKeysAuthenticator)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetAuthorizedKeysAuthenticator | authorizedKeysAuthenticator | The authorized keys configuration. |
SetAuthorizedKeysAuthenticator(string)
Enables public key authentication backed by an authorized_keys file path.
Declaration
public void SetAuthorizedKeysAuthenticator(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The authorized_keys file path. |
SetAuthorizedkeyAuthenticator(IAMNetAuthorizedKeysAuthenticator)
Enables public key authentication backed by an authorized_keys file.
Declaration
public void SetAuthorizedkeyAuthenticator(IAMNetAuthorizedKeysAuthenticator authorizedKeysAuthenticator)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetAuthorizedKeysAuthenticator | authorizedKeysAuthenticator | The authorized keys configuration. |
SetAuthorizedkeyAuthenticator(string)
Enables public key authentication backed by an authorized_keys file path.
Declaration
public void SetAuthorizedkeyAuthenticator(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The authorized_keys file path. |
SetCompositePasswordAuthenticator(params IAMNetPasswordAuthenticator[])
Enables username/password authentication using multiple modules evaluated in order.
Declaration
public void SetCompositePasswordAuthenticator(params IAMNetPasswordAuthenticator[] authenticators)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetPasswordAuthenticator[] | authenticators | The password authenticators to try. |
SetCompositePublicKeyAuthenticator(params IAMNetPublickeyAuthenticator[])
Enables public key authentication using multiple modules evaluated in order.
Declaration
public void SetCompositePublicKeyAuthenticator(params IAMNetPublickeyAuthenticator[] authenticators)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetPublickeyAuthenticator[] | authenticators | The public key authenticators to try. |
SetCompositePublickeyAuthenticator(params IAMNetPublickeyAuthenticator[])
Enables public key authentication using multiple modules evaluated in order.
Declaration
public void SetCompositePublickeyAuthenticator(params IAMNetPublickeyAuthenticator[] authenticators)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetPublickeyAuthenticator[] | authenticators | The public key authenticators to try. |
SetDelegateKeyboardInteractiveAuthenticator(Action<string, ISshChallenge>, Func<ISshSession, string, IResponseList, bool>)
Enables keyboard-interactive authentication using .NET callbacks.
Declaration
public void SetDelegateKeyboardInteractiveAuthenticator(Action<string, ISshChallenge> generateChallenge, Func<ISshSession, string, IResponseList, bool> authenticate)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<string, ISshChallenge> | generateChallenge | Callback that populates prompts sent to the client. |
| Func<ISshSession, string, IResponseList, bool> | authenticate | Callback that validates the client responses. |
SetDelegatePasswordAuthenticator(Func<string, string, ISshSession, bool>)
Enables username/password authentication using a .NET callback.
Declaration
public void SetDelegatePasswordAuthenticator(Func<string, string, ISshSession, bool> authenticate)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<string, string, ISshSession, bool> | authenticate | Callback that receives username, password, and session metadata and returns whether the credentials should be accepted. |
SetDelegatePublicKeyAuthenticator(Func<string, string, ISshSession, bool>)
Enables public key authentication using a .NET callback.
Declaration
public void SetDelegatePublicKeyAuthenticator(Func<string, string, ISshSession, bool> authenticate)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<string, string, ISshSession, bool> | authenticate | Callback that receives username, public key fingerprint, and session metadata and returns whether the key should be accepted. |
SetDelegatePublickeyAuthenticator(Func<string, string, ISshSession, bool>)
Enables public key authentication using a .NET callback.
Declaration
public void SetDelegatePublickeyAuthenticator(Func<string, string, ISshSession, bool> authenticate)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<string, string, ISshSession, bool> | authenticate | Callback that receives username, public key fingerprint, and session metadata and returns whether the key should be accepted. |
SetFingerprintPublicKeyAuthenticator(string, params string[])
Enables public key authentication for one username and one or more accepted fingerprints.
Declaration
public void SetFingerprintPublicKeyAuthenticator(string username, params string[] acceptedFingerprints)
Parameters
| Type | Name | Description |
|---|---|---|
| string | username | The exact username to accept. |
| string[] | acceptedFingerprints | One or more accepted public key fingerprints. |
SetFingerprintPublickeyAuthenticator(string, params string[])
Enables public key authentication for one username and one or more accepted fingerprints.
Declaration
public void SetFingerprintPublickeyAuthenticator(string username, params string[] acceptedFingerprints)
Parameters
| Type | Name | Description |
|---|---|---|
| string | username | The exact username to accept. |
| string[] | acceptedFingerprints | One or more accepted public key fingerprints. |
SetFixedKeyboardInteractiveAuthenticator(string, string?, string, string, string)
Enables keyboard-interactive authentication with a single fixed response.
Declaration
public void SetFixedKeyboardInteractiveAuthenticator(string expectedResponse, string? username = null, string prompt = "Verification code", string interactionName = "Authentication", string instruction = "Enter the verification code.")
Parameters
| Type | Name | Description |
|---|---|---|
| string | expectedResponse | The exact response to accept. |
| string | username | Optional exact username to accept. |
| string | prompt | Prompt text shown to the client. |
| string | interactionName | Challenge name shown to the client. |
| string | instruction | Instruction text shown with the challenge. |
SetFixedPasswordAuthenticator(string, string)
Enables a single fixed username/password pair.
Declaration
public void SetFixedPasswordAuthenticator(string username, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| string | username | The exact username to accept. |
| string | password | The exact password to accept. |
SetKeyboardInteractiveAuthenticator(IAMNetKeyboardInteractiveAuthenticator)
Enables keyboard-interactive authentication.
Declaration
public void SetKeyboardInteractiveAuthenticator(IAMNetKeyboardInteractiveAuthenticator keyboardInteractiveAuthenticator)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetKeyboardInteractiveAuthenticator | keyboardInteractiveAuthenticator | The application authenticator. |
SetPasswordAuthenticator(IAMNetPasswordAuthenticator)
Enables username/password authentication.
Declaration
public void SetPasswordAuthenticator(IAMNetPasswordAuthenticator passwordAuthenticator)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetPasswordAuthenticator | passwordAuthenticator | The application authenticator. |
SetPublicKeyAuthenticator(IAMNetPublickeyAuthenticator)
Enables public key authentication.
Declaration
public void SetPublicKeyAuthenticator(IAMNetPublickeyAuthenticator publickeyAuthenticator)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetPublickeyAuthenticator | publickeyAuthenticator | The application authenticator. |
SetPublickeyAuthenticator(IAMNetPublickeyAuthenticator)
Enables public key authentication.
Declaration
public void SetPublickeyAuthenticator(IAMNetPublickeyAuthenticator publickeyAuthenticator)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetPublickeyAuthenticator | publickeyAuthenticator | The application authenticator. |
SetUpDefaultServer()
Creates a server with the default SSH server factories.
Declaration
public static AMNetSshServer SetUpDefaultServer()
Returns
| Type | Description |
|---|---|
| AMNetSshServer |
Start()
Starts accepting SSH connections.
Declaration
public void Start()
Stop()
Stops the server and closes active resources using the server default shutdown behavior.
Declaration
public void Stop()
Stop(bool)
Stops the server.
Declaration
public void Stop(bool immediately)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | immediately | When |
addSessionListener(IAMNetSessionListener)
Registers session lifecycle callbacks.
Declaration
public void addSessionListener(IAMNetSessionListener sessionListener)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetSessionListener | sessionListener | The session listener to add. |
getConfiguredAuthenticationMethods()
Gets the configured authentication method chains in evaluation order.
Declaration
public IReadOnlyList<IReadOnlyList<string>> getConfiguredAuthenticationMethods()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<IReadOnlyList<string>> |
getHost()
Gets the configured bind address.
Declaration
public string? getHost()
Returns
| Type | Description |
|---|---|
| string |
getPort()
Gets the TCP port the SSH server listens on.
Declaration
public int getPort()
Returns
| Type | Description |
|---|---|
| int |
isClosed()
Returns whether the server has been closed.
Declaration
public bool isClosed()
Returns
| Type | Description |
|---|---|
| bool |
isStarted()
Returns whether the server has been started.
Declaration
public bool isStarted()
Returns
| Type | Description |
|---|---|
| bool |
setAuthenticationMethodGroups(params IEnumerable<string>[])
Sets the authentication method policy using one or more required method groups.
Declaration
public void setAuthenticationMethodGroups(params IEnumerable<string>[] authenticationMethodGroups)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<string>[] | authenticationMethodGroups | Each group contains methods that must all succeed in order. The outer set represents alternative groups. |
setAuthenticationMethods(params string[])
Sets the authentication method policy using one or more pre-built method chains.
Declaration
public void setAuthenticationMethods(params string[] authenticationChains)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | authenticationChains | Authentication chains such as PublicKey or values returned by RequireAll(params string[]). |
setAuthorizedkeyAuthenticator(IAMNetAuthorizedKeysAuthenticator)
Enables public key authentication backed by an authorized_keys file.
Declaration
public void setAuthorizedkeyAuthenticator(IAMNetAuthorizedKeysAuthenticator authorizedKeysAuthenticator)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetAuthorizedKeysAuthenticator | authorizedKeysAuthenticator | The authorized keys configuration. |
setAuthorizedkeyAuthenticator(string)
Enables public key authentication backed by an authorized_keys file path.
Declaration
public void setAuthorizedkeyAuthenticator(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The authorized_keys file path. |
setCommandFactory(AMNetScpCommandFactory)
Enables SCP command handling for incoming SSH sessions.
Declaration
public void setCommandFactory(AMNetScpCommandFactory scpFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| AMNetScpCommandFactory | scpFactory | The SCP command factory. |
setCompositePasswordAuthenticator(params IAMNetPasswordAuthenticator[])
Enables username/password authentication using multiple modules evaluated in order.
Declaration
public void setCompositePasswordAuthenticator(params IAMNetPasswordAuthenticator[] authenticators)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetPasswordAuthenticator[] | authenticators | The password authenticators to try. |
setCompositePublickeyAuthenticator(params IAMNetPublickeyAuthenticator[])
Enables public key authentication using multiple modules evaluated in order.
Declaration
public void setCompositePublickeyAuthenticator(params IAMNetPublickeyAuthenticator[] authenticators)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetPublickeyAuthenticator[] | authenticators | The public key authenticators to try. |
setDelegateKeyboardInteractiveAuthenticator(Action<string, ISshChallenge>, Func<ISshSession, string, IResponseList, bool>)
Enables keyboard-interactive authentication using .NET callbacks.
Declaration
public void setDelegateKeyboardInteractiveAuthenticator(Action<string, ISshChallenge> generateChallenge, Func<ISshSession, string, IResponseList, bool> authenticate)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<string, ISshChallenge> | generateChallenge | Callback that populates prompts sent to the client. |
| Func<ISshSession, string, IResponseList, bool> | authenticate | Callback that validates the client responses. |
setDelegatePasswordAuthenticator(Func<string, string, ISshSession, bool>)
Enables username/password authentication using a .NET callback.
Declaration
public void setDelegatePasswordAuthenticator(Func<string, string, ISshSession, bool> authenticate)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<string, string, ISshSession, bool> | authenticate | Callback that receives username, password, and session metadata and returns whether the credentials should be accepted. |
setDelegatePublickeyAuthenticator(Func<string, string, ISshSession, bool>)
Enables public key authentication using a .NET callback.
Declaration
public void setDelegatePublickeyAuthenticator(Func<string, string, ISshSession, bool> authenticate)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<string, string, ISshSession, bool> | authenticate | Callback that receives username, public key fingerprint, and session metadata and returns whether the key should be accepted. |
setFileSystemFactory(AMNetVirtualFileSystemFactory)
Sets the virtual filesystem factory used to map users to server-side home directories.
Declaration
public void setFileSystemFactory(AMNetVirtualFileSystemFactory fileSystemFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| AMNetVirtualFileSystemFactory | fileSystemFactory | The filesystem factory configuration. |
setFingerprintPublickeyAuthenticator(string, params string[])
Enables public key authentication for one username and one or more accepted fingerprints.
Declaration
public void setFingerprintPublickeyAuthenticator(string username, params string[] acceptedFingerprints)
Parameters
| Type | Name | Description |
|---|---|---|
| string | username | The exact username to accept. |
| string[] | acceptedFingerprints | One or more accepted public key fingerprints. |
setFixedKeyboardInteractiveAuthenticator(string, string?, string, string, string)
Enables keyboard-interactive authentication with a single fixed response.
Declaration
public void setFixedKeyboardInteractiveAuthenticator(string expectedResponse, string? username = null, string prompt = "Verification code", string interactionName = "Authentication", string instruction = "Enter the verification code.")
Parameters
| Type | Name | Description |
|---|---|---|
| string | expectedResponse | The exact response to accept. |
| string | username | Optional exact username to accept. |
| string | prompt | Prompt text shown to the client. |
| string | interactionName | Challenge name shown to the client. |
| string | instruction | Instruction text shown with the challenge. |
setFixedPasswordAuthenticator(string, string)
Enables a single fixed username/password pair.
Declaration
public void setFixedPasswordAuthenticator(string username, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| string | username | The exact username to accept. |
| string | password | The exact password to accept. |
setHost(string?)
Sets the bind address. Use null to use the server default.
Declaration
public void setHost(string? host)
Parameters
| Type | Name | Description |
|---|---|---|
| string | host | The IP address or host name to bind. |
setIoServiceEventListener(IAMNetIoServiceEventListener)
Registers low-level I/O service callbacks.
Declaration
public void setIoServiceEventListener(IAMNetIoServiceEventListener serverIoServiceEventListener)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetIoServiceEventListener | serverIoServiceEventListener | The low-level connection listener. |
setKeyPairProvider(AMNetSimpleGeneratorHostKeyProvider)
Sets the host key provider used to identify this SSH server to clients.
Declaration
public void setKeyPairProvider(AMNetSimpleGeneratorHostKeyProvider keyProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| AMNetSimpleGeneratorHostKeyProvider | keyProvider | The host key provider configuration. |
setKeyboardInteractiveAuthenticator(IAMNetKeyboardInteractiveAuthenticator)
Enables keyboard-interactive authentication.
Declaration
public void setKeyboardInteractiveAuthenticator(IAMNetKeyboardInteractiveAuthenticator keyboardInteractiveAuthenticator)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetKeyboardInteractiveAuthenticator | keyboardInteractiveAuthenticator | The application authenticator. |
setPasswordAuthenticator(IAMNetPasswordAuthenticator)
Enables username/password authentication.
Declaration
public void setPasswordAuthenticator(IAMNetPasswordAuthenticator passwordAuthenticator)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetPasswordAuthenticator | passwordAuthenticator | The application authenticator. |
setPort(int)
Sets the TCP port the SSH server listens on.
Declaration
public void setPort(int port)
Parameters
| Type | Name | Description |
|---|---|---|
| int | port | The TCP port number. |
setPublickeyAuthenticator(IAMNetPublickeyAuthenticator)
Enables public key authentication.
Declaration
public void setPublickeyAuthenticator(IAMNetPublickeyAuthenticator publickeyAuthenticator)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetPublickeyAuthenticator | publickeyAuthenticator | The application authenticator. |
setServerProxyAcceptor(IAMNetServerProxyAcceptor)
Enables PROXY protocol metadata handling before the SSH handshake.
Declaration
public void setServerProxyAcceptor(IAMNetServerProxyAcceptor serverProxyAcceptor)
Parameters
| Type | Name | Description |
|---|---|---|
| IAMNetServerProxyAcceptor | serverProxyAcceptor | The acceptor that parses and validates proxy metadata. |
setSubsystemFactories(AMNetSftpSubsystemFactory)
Enables the SFTP subsystem for incoming SSH sessions.
Declaration
public void setSubsystemFactories(AMNetSftpSubsystemFactory sftpFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| AMNetSftpSubsystemFactory | sftpFactory | The SFTP subsystem factory. |
setUpDefaultServer()
Creates a server with the default SSH server factories.
Declaration
public static AMNetSshServer setUpDefaultServer()
Returns
| Type | Description |
|---|---|
| AMNetSshServer |
start()
Starts accepting SSH connections.
Declaration
public void start()
stop()
Stops the server and closes active resources using the server default shutdown behavior.
Declaration
public void stop()
stop(bool)
Stops the server.
Declaration
public void stop(bool immediately)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | immediately | When |