sshmitm.clients.ssh module

The module provides a set of classes for implementing SSH-MITM clients in Python.

The AuthenticationMethod class is a helper class that provides different methods for authentication to a remote ssh server. It provides methods for authentication using passwords, private key files, and key-pair certificates. This class makes it easy to use different authentication methods in a consistent manner.

The BaseSSHClient class is an abstract class that provides the basic functionality for an ssh client. This class provides methods to connect to a remote server, create and use secure shell channels, and execute commands on the remote server. It is designed to be extended and customized for specific use cases.

The SSHClient class is a concrete implementation of the BaseSSHClient class. This class provides a high-level API for connecting to remote servers and performing operations over ssh. It uses the Paramiko library under the hood to handle the underlying ssh connectivity. This class makes it easy to connect to remote servers, execute commands, and transfer files.

class sshmitm.clients.ssh.AuthenticationMethod(value)

Bases: Enum

An enumeration of possible authentication methods that can be used to connect to a remote host.

AGENT = 'agent'
PASSWORD = 'password'
PUBLICKEY = 'publickey'
class sshmitm.clients.ssh.BaseSSHClient(args: Optional[Sequence[str]] = None, namespace: Optional[Namespace] = None, **kwargs: Any)

Bases: BaseModule

” The base class for an SSH client module.

class sshmitm.clients.ssh.SSHClient(host: str, port: int, method: AuthenticationMethod, password: Optional[str], user: str, key: Optional[PKey], session: Session)

Bases: BaseSSHClient

The SSH client class, used to connect to a remote host.

  • host (str) – the hostname or IP address of the remote host

  • port (int) – the port number to connect to on the remote host

  • method (AuthenticationMethod) – the authentication method to use when connecting

  • password (Optional[str]) – the password to use for authentication (if method is password)

  • user (str) – the username to use for authentication

  • key (Optional[PKey]) – the public key to use for authentication (if method is publickey)

  • session ('sshmitm.session.Session') – the session instance

check_host_key(hostname: str, keytype: str, key: PKey) bool

Check the host key.

  • hostname (str) – Hostname of the remote server.

  • keytype (str) – Type of the key.

  • key (paramiko.pkey.PKey) – Key of the remote server.


True if the host key is valid, False otherwise.

Return type:


connect() bool

Connects to the remote host using the specified authentication method.


True if the connection was successful, False otherwise

Return type: