# Shells and files

Every machine is reachable by plain `ssh`, using its name as the login. Each of these wakes the
machine if it's asleep.

```sh
ssh -t ubuntu-1@shell.639cloud.com                        # root shell
ssh ubuntu-1@shell.639cloud.com 'apt-get install -y jq'   # one command; exits with its code
scp app.py ubuntu-1@shell.639cloud.com:/root/             # upload
scp ubuntu-1@shell.639cloud.com:/root/out.csv .           # download
sftp ubuntu-1@shell.639cloud.com
```

A one-shot command runs for at most 10 minutes this way; use `keepawake` with `nohup` for longer
jobs. Commands from the API (`timeout_seconds`, default 120 s, up to 3600) and from an agent's
`exec` tool (default 120 s, up to 600; a longer timeout is refused, not shortened) are stopped in the machine at their timeout, along with
everything they started: the result says `timed_out`, with exit code 124 and the output so far. A machine stays awake while you are attached or a transfer runs.

## Port forwarding

Reach a port on one of your machines from your own computer, through 639 Shell:

```sh
ssh -N -L 8080:web-1:80 shell.639cloud.com      # then open http://localhost:8080
ssh -N -L 5901:desk-1:5900 shell.639cloud.com   # a VNC viewer on localhost:5901
```

The destination is one of your machines, by name. It wakes the machine and keeps it awake while
the forward is open. Only your own machines (and your team's) can be reached this way, and it
takes the access a shell does (a viewer can't forward). At most 16 forwards on one connection and
64 open in your org at once; each is in the machine's history as `forward`. `-L` only: remote
(`-R`) and SOCKS (`-D`) forwarding are refused.

With required rules on the machine, file transfers (scp, sftp) and `ssh web-1@… 'cmd'` commands
wait until your key acknowledges them (see Rules for agents); an interactive shell is never
refused, it shows the rules when it opens.

## Use your own SSH config

Put your machines in your computer's SSH setup, so `ssh web-1`, `scp web-1:file .` and VS Code
Remote-SSH just work:

```sh
ssh export@shell.639cloud.com ssh-config > ~/.ssh/639.conf
```

Then add this once, at the top of `~/.ssh/config`:

```
Include 639.conf
```

Re-run the export after creating or deleting machines. For scripts, there is JSON too:

```sh
ssh export@shell.639cloud.com json > 639.json
```

Nothing secret is exported.
