# 22 - SSH

## Introduction

**Port**: 22 (TCP) The **Secure Shell** (SSH) protocol is used for operating network services and transferring files securely over an unsecured network.

## Basic enumeration

Default enumeration:

```bash
nmap -p22 -sC -sV -n <TARGET>
```

To obtain the number of algorithms supported by the server and how to add them if they are not supported by default.

```bash
sudo nmap --script=ssh2-enum-algos -p22 -n <TARGET>ssh <USER>@<IP> -oKexAlgorithms=+diffie-hellman-group1-sha1 
```

To obtain the SSH server's key fingerprint. If the host key has been reused and it is [publicly known](https://github.com/rapid7/ssh-badkeys/tree/master/authorized), the attacker could lead to MITM attacks.

```bash
sudo nmap --script=ssh-hostkey -p22 -n <TARGET>
```

To check support for SSHv1.

```bash
sudo nmap --script=sshv1 -p22 -n <TARGET>
```

This command returns authentication methods that an SSH server supports (The username may be invalid).

```bash
sudo nmap --script=ssh-auth-methods --script-args="ssh.user=<USERNAME>" -p22 -n <TARGET>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://the-pentesting-guide.marmeus.com/active/services/22-ssh.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
