This repo contains a NixOS module which hides both HTTP and SSH daemons behind HTTPS proxy on a same port.
This repo should be considered as a draft.
- Add the module to your system's config like this
{
# ...
require = [
../path/to/ssh-over-tls/nix/default.nix
];
# ...
services.ssh-over-tls = {
cert_pem = ../stunnel.pem;
sshd_port = 22;
httpd_port = 80;
tls_port = 443;
};
# ...
}
-
Run
sh sh/genkeys.sh
to generate Stunnel certificates. Set upcert_pem
to point to the PEM-file produced. Copy it to your clients. -
Make sure your SSH and HTTPD servers are set up correctly (we assume they use ports 22 and 80 in the example above).
-
On the server, build the system with
nixos-rebuild switch
-
On the client, run
- Stunnel client pointing to server's SSL port:
where IP is the server's IP. Port 3443 is picked at will.
sh sh/client.sh -L 3443 IP:443
- SSH to the client's local port 3443:
The connection will be forwarded to your server's SSHD using SSL protocol. Use
ssh -p 3443 127.0.0.1
-L/-R/-D
ssh forwarding as needed.
- Stunnel client pointing to server's SSL port: