Quickstart

SSH-MITM is a man in the middle SSH Server for security audits and malware analysis.

Password and publickey authentication are supported and SSH-MITM is able to detect, if a user is able to login with publickey authentication on the remote server. This allows SSH-MITM to acccept the same key as the destination server. If publickey authentication is not possible, the authentication will fall back to password-authentication.

When publickey authentication is possible, a forwarded agent is needed to login to the remote server. In cases, when no agent was forwarded, SSH-MITM can rediredt the session to a honeypot.

SSH-MITM intercepting password login

ssh man-in-the-middle (ssh-mitm) server for security audits supporting
publickey authentication, session hijacking and file manipulation

Get it from the Snap Store

1Install SSH-MITM

To install SSH-MITM, simply run this command in your terminal of choice:
$ sudo snap install ssh-mitm

Get it from the Snap Store

2Connect to the network

To start an intercepting mitm-ssh server on Port 10022, all you have to do is run a single command.
$ ssh-mitm --remote-host 192.168.0.x:PORT

Now let's try to connect to the ssh-mitm server.
$ ssh -p 10022 user@proxyserver

3Hijack SSH sessions

When a client connects, the ssh-mitm starts a new server, which is used for session hijacking.
[INFO] created injector shell on port 34463

To hijack this session, you can use your favorite ssh client. All you have to do is to connect to the hijacked session.
$ ssh -p 34463 127.0.0.1

Alternative installation methods

This part of the documentation covers the installation of SSH-MITM. The first step to using any software package is getting it properly installed.

To install SSH-MITM, simply run one of those commands in your terminal of choice:

Install as snap

$ sudo snap install ssh-mitm

Install with pip

$ python -m pip install ssh-mitm

Install as AppImage

$ wget https://github.com/ssh-mitm/ssh-mitm/releases/latest/download/ssh-mitm-x86_64.AppImage
$ chmod +x ssh-mitm*.AppImage

Start SSH-MITM

Let’s get started with some simple examples.

Starting an intercepting mitm-ssh server with password authentication is very simple.

All you have to do is run this command in your terminal of choice.

$ ssh-mitm --remote-host 192.168.0.x:PORT

Now let’s try to connect to the ssh-mitm server. The ssh-mitm server is listening on port 10022.

$ ssh -p 10022 testuser@proxyserver

You will see the credentials in the log output.

INFO     Remote authentication succeeded
    Remote Address: 127.0.0.1:22
    Username: testuser
    Password: secret
    Agent: no agent

Hijack a SSH terminal session

Getting the plain text credentials is only half the fun. SSH-MITM proxy server is able to hijack a ssh session and allows you to interact with it.

Let’s get started with hijacking the session.

When a client connects, the ssh-mitm proxy server starts a new server, where you can connect with another ssh client. This server is used to hijack the session.

INFO     ℹ created mirrorshell on port 34463. connect with: ssh -p 34463 127.0.0.1

To hijack the session, you can use your favorite ssh client. This connection does not require authentication.

$ ssh -p 34463 127.0.0.1

After you are connected, your session will only be updated with new responses, but you are able to execute commands.

Try to execute somme commands in the hijacked session or in the original session.

The output will be shown in both sessions.

Publickey authentication

SSH-MITM is able to verify, if a user is able to login with publickey authentication on the remote server. If publickey authentication is not possible, SSH-MITM falls back to password authentication. This step does not require a forwarded agent.

For a full login on the remote server agent forwarding is still required. When no agent was forwarded, SSH-MITM can redirect the connection to a honeypot.

$ ssh-mitm --fallback-host username:password@hostname:port