# 22 - SSH

## Nmap

Para facilitar información de este puerto puedes usar sus NSE's correspondientes

{% code overflow="wrap" %}

```
#opcion 1 - todos los que contengan *ssh* en el NSE
nmap -p 22 -sV --script=*ssh* IP

#opcion 2 - específicamente los siguientes
nmap -p 22 -sV --script=ssh-auth-methods,ssh-run,ssh2-enum-algos,ssh-publickey-acceptance,ssh-hostkey IP
```

{% endcode %}

## Probar

### Fuerza bruta

* Hydra:

```bash
hydra -l root -P /usr/share/wordlists/rockyou.txt IP -t 4 ssh
```

{% code overflow="wrap" %}

```bash
hydra -L /usr/share/wordlists/rockyou.txt -P /usr/share/wordlists/rockyou.txt IP -t 4 ssh
```

{% endcode %}

## A tener en cuenta

* En el caso de mostrar el siguiente mensaje de error al intentar autenticarte:

no matching key exchange method found. Their offer: gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

Usa:

```bash
ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 user@IP -p port
```

* Para crear clave publica con clave privada RSA:

<https://www.tbs-certificates.co.uk/FAQ/en/utiliser-cle-openssl-sous-openssh.html>

* Para conectarnos a este servicio usaremos los siguientes comandos:

```
ssh user@IP

ssh user@IP -i id.rsa
```

## Máquinas resueltas que usan SSH

* HTB
  * Cap
  * Latte
  * Forge
  * TwoMillion

## Referencias


---

# 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://wiki.securiters.com/securiters-wiki/puertos-and-servicios/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.
