# apt updates for a NAS with no internet, through ssh -R

my NAS sits on a cable straight into my laptop and nothing else. no route out, by choice. that's fine until it needs updates.

## the tunnel

[`ssh -R`](https://man.openbsd.org/ssh#R) with only a port and no destination makes the remote end a SOCKS proxy that exits through your machine:

```bash
# from the laptop: NAS:1080 becomes a SOCKS proxy out through here
ssh -f -N -R 127.0.0.1:1080 -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 root@<nas>
```

then tell apt on the NAS to use it:

```bash
# /etc/apt/apt.conf.d/99-tmp-socks-tunnel
Acquire::http::Proxy "socks5h://127.0.0.1:1080";
Acquire::https::Proxy "socks5h://127.0.0.1:1080";
```

[`socks5h`](https://manpages.debian.org/bookworm/apt/apt-transport-http.1.en.html), with the h, means DNS resolves on the laptop's side too. apt 1.4 and up speak `socks5h`, so any current Debian has it.

tear down in reverse: delete the apt conf first, then kill the tunnel.

## things that got in the way

openmediavault ships with `AllowTcpForwarding no`. don't fix that in `sshd_config`, `omv-salt` rewrites it. set it through OMV's own SSH settings with `omv-rpc` (`tcpforwarding:true`).

run long upgrades detached, `setsid nohup … &` with a log, so a dropped ssh session doesn't kill dpkg halfway.

and only apt follows the proxy. anything that shells out to `wget` or `curl` goes direct and gets nowhere. omv-extras' postinst fetches its signing key with `wget`, and on my box that silently wrote a 0-byte `/usr/share/keyrings/omvextras.gpg`. the fix was fetching the key on the laptop, checking its fingerprint, and `scp`-ing it across.
