# SSH (22)

<details>

<summary>Protocol Information</summary>

SSH (Secure Shell) is a remote administration protocol that offers encryption and is the successor to Telnet. It is generally used for remote access to servers and systems.\
SSH authentication can be configured in two main ways: user/password, or with key.

</details>

## Port

<table data-header-hidden><thead><tr><th width="166">Port</th><th>Description</th></tr></thead><tbody><tr><td><mark style="color:green;"><strong>22</strong></mark><strong> TCP</strong></td><td>SSH</td></tr></tbody></table>

## Config File

* **Linux**: `/etc/ssh/sshd_config`
* **Windows**: `%ProgramData%\ssh\sshd_config`

## Interact

If **anonymous access** is enabled, it's possible log in with username `“Anonymous”` and password `“”`.

{% code overflow="wrap" %}

```bash
ssh <USER>@<IP>
```

{% endcode %}

{% code overflow="wrap" %}

```bash
ssh -i <KEY> <USER>@<IP>
```

{% endcode %}

### SSH Key

{% code overflow="wrap" %}

```bash
ssh-keygen
```

{% endcode %}

Move the public key in `~/.ssh/authorized_keys` target machine (append if it already exists).

{% code overflow="wrap" %}

```bash
cat id_rsa.pub >> authorized_keys
```

{% endcode %}

| Algorithm             | Private Key  | Public Key       |
| --------------------- | ------------ | ---------------- |
| RSA                   | `id_rsa`     | `id_rsa.pub`     |
| DSA (obsolete)        | `id_dsa`     | `id_dsa.pub`     |
| ECDSA                 | `id_ecdsa`   | `id_ecdsa.pub`   |
| Ed25519 (recommended) | `id_ed25519` | `id_ed25519.pub` |

### Upload Key on Server SSH

{% code overflow="wrap" %}

```bash
ssh-keygen -f ~/.ssh/id_rsa -N ""
ssh-copy-id -i ~/.ssh/id_rsa.pub <USER>@<IP>
```

{% endcode %}

### scp

```bash
scp [-r] [-O] <USER>@<IP>:/<REMOTE_FILE> /<TO_LOCAL>
scp [-r] [-O] /<LOCAL_FILE> <USER>@<IP>:/<TO_REMOTE>
```


---

# 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://ivalexev.gitbook.io/rednote/utility/service/ssh-22.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.
