# SSH

## Recipes

* Connect to host:

```bash
ssh -A username@server
```

> -A enables forwarding of the authentication agent connection. In other words you can connect to another ssh server from current ssh server

* Mount folder on host with `sshfs`:

```bash
sshfs username@server:/path-on-server/ ~/path-to-mount-point -o reconnect
```

* Copy over SSH (actually the best way is mounting with `sshfs`):

```bash
# from local to remote
scp file.txt username@server:/path-on-server/

# from remote to local
scp username@server:/path-on-server/file.txt  file.txt

# copy all files and folders recursively from local to remote
scp -r * username@server:/path-on-server/
```

* Add your SSH key to the ssh-agent:

```bash
ssh-add ~/path-to-key
```

## Links

* [ssh -A explained](https://superuser.com/questions/1376111/with-ssh-what-does-the-a-flag-do/1376118)
* [Copy files over SSH](https://www.simplified.guide/ssh/copy-file)


---

# 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://avmaslakov.gitbook.io/memoria/networking/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.
