# SSH

### Artigos

* [A Visual Guide to SSH Tunnels: Local and Remote Port Forwarding](https://iximiuz.com/en/posts/ssh-tunnels/)

### Links Úteis

* [Generating a new SSH key and adding it to the ssh-agent](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)

### Cheat Sheet

#### Gerar par de chaves SSH

{% code title="Gerar par de chaves ssh ed25519" %}

```bash
ssh-keygen -t ed25519 -C "your_email@example.com"
```

{% endcode %}

Ele vai perguntar o local onde salvar a chave (padrão `~/.ssh/id_ed25519`), `senha` e `confirmar senha`.

Ele vai gerar duas chaves:

{% code title="PRIVADA: \~/.ssh/id\_ed25519" %}

```bash
cat ~/.ssh/id_ed25519
```

{% endcode %}

{% code title="Output" %}

```
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACAF9+5BkCMDAJ84w+WlhU9glZKU12sXRzW+Hj1pElaz7gAAAKCzsjUts7I1
LQAAAAtzc2gtZWQyNTUxOQAAACAF9+5BkCMDAJ84w+WlhU9glZKU12sXRzW+Hj1pElaz7g
AAAEAjwc/egakGFdlhXxU2WK15Dtu1fnguQwQQKdCDwJWPuQX37kGQIwMAnzjD5aWFT2CV
kpTXaxdHNb4ePWkSVrPuAAAAFnlvdXJfZW1haWxAZXhhbXBsZS5jb20BAgMEBQYH
-----END OPENSSH PRIVATE KEY-----
```

{% endcode %}

{% code title="PÚBLICA: \~/.ssh/id\_ed25519.pub" %}

```bash
cat ~/.ssh/id_ed25519.pub
```

{% endcode %}

{% hint style="warning" %}
A chave privada (`id_ed25519`) nunca deve ser exposta, nunca deve sair do seu computador, não passe ela para ninguém.

Em serviços (como github ou gitlab), use SEMPRE a chave pública (`id_ed25519.pub`).
{% endhint %}


---

# 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://ben-hurs-organization.gitbook.io/guia-de-appsec/command-line/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.
