nixos-config/packages/portfwd.nix
Sridhar Ratnakumar 87d306bb33 portfwd
2026-06-02 17:21:29 -04:00

20 lines
556 B
Nix

{ writeShellApplication, openssh, ... }:
writeShellApplication {
name = "portfwd";
meta.description = ''
Forward a local port to the same port on a remote host over SSH.
Usage: portfwd <port> [host] (host defaults to pureintent)
e.g. `portfwd 7721` or `portfwd 7721 sincereintent`
'';
runtimeInputs = [ openssh ];
text = ''
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
echo "usage: portfwd <port> [host]" >&2
exit 1
fi
port="$1"
host="''${2:-pureintent}"
ssh -L "$port:localhost:$port" "$host"
'';
}