You must setup Lighttpd and Cloudflared first.
Steps
- create ttyd directory in $HOME
mkdir -p ~/ttyd && cd ~/ttyd - download latest version of ttyd and trzsz
curl -LO "https://download.freaks.dev/compiled/ttyd" latest=$(basename $(curl -fs -o/dev/null -w %{redirect_url} https://github.com/trzsz/trzsz-go/releases/latest)) curl -LO "https://github.com/trzsz/trzsz-go/releases/download/${latest}/trzsz_${latest#v}_linux_x86_64.tar.gz" tar -xzf trzsz_${latest#v}_linux_x86_64.tar.gz mv trzsz_${latest#v}_linux_x86_64/* ~/.local/bin/ rm -r trzsz* - copy from ttyd.service
nano ttyd.service - start ttyd service
cp ~/ttyd/ttyd.service ~/.config/systemd/user/ systemctl --user daemon-reload systemctl --user enable --now ttyd - copy from ttyd.conf
nano ~/lighttpd/conf.d/ttyd.conf - create auth for ttyd
printf "<username>:$(openssl passwd -6 <password>)" > ~/lighttpd/passwd/.ttyd - restart lighttpd
systemctl --user restart lighttpd
ttyd.service
[Unit]
Description=ttyd
Wants=network-online.target
After=network-online.target
[Service]
Restart=always
ExecStart=%h/ttyd/ttyd -p 1341 -i lo -o -t enableTrzsz=true -t fontSize=16 bash
[Install]
WantedBy=default.target
ttyd.conf
$HTTP["host"] == "ttyd.example.com" {
auth.backend = "htpasswd"
auth.backend.htpasswd.userfile= env.HOME + "/lighttpd/passwd/.ttyd"
auth.require = ( "" =>
(
"method" => "basic",
"realm" => "Restricted!",
"require" => "valid-user"
),
)
proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "1341" ) ) )
proxy.header = ( "upgrade" => "enable" )
}