diff --git a/auto-ssh-systemd-hosts.conf b/auto-ssh-systemd-hosts.conf new file mode 100644 index 0000000..22d3ff2 --- /dev/null +++ b/auto-ssh-systemd-hosts.conf @@ -0,0 +1,10 @@ +Host bpfilip.dk + HostName bpfilip.dk + IdentityFile /root/.ssh/id_rsa + User root + Port 2223 + LocalForward 22 127.0.0.1:2222 + RemoteForward 2222 127.0.0.1:22 + RemoteForward 10.0.1.25:8080 127.0.0.1:8080 + GatewayPorts yes + Compression yes diff --git a/autossh.service b/autossh.service new file mode 100644 index 0000000..e76ead8 --- /dev/null +++ b/autossh.service @@ -0,0 +1,13 @@ +[Unit] +Description=Keeps an SSH tunnel to 'bpfilip.dk' open +After=network-online.target + +[Service] +User=root +ExecStart=/usr/bin/autossh -M 0 -N -q -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" bpfilip.dk +ExecStop=/usr/bin/killall -s KILL autossh +Restart=always +RestartSec=3 + +[Install] +WantedBy=multi-user.target diff --git a/install.sh b/install.sh index a3f2d17..4f3d13d 100644 --- a/install.sh +++ b/install.sh @@ -25,16 +25,18 @@ cat smb.conf | sudo tee -a /etc/samba/smb.conf sudo systemctl restart smbd +sudo cp auto-ssh-systemd-hosts.conf /etc/ssh/ssh_config.d/auto-ssh-systemd-hosts.conf + sudo cp video-player.service /etc/systemd/system/video-player.service sudo cp video-player2.service /etc/systemd/system/video-player2.service -sudo cp ngrok.service /etc/systemd/system/ngrok.service +sudo cp autossh.service /etc/systemd/system/autossh.service sudo systemctl daemon-reload sudo systemctl enable video-player.service sudo systemctl disable video-player2.service -sudo systemctl enable ngrok.service +sudo systemctl enable autossh.service sudo systemctl restart video-player.service sudo systemctl restart video-player2.service -sudo systemctl restart ngrok.service +sudo systemctl restart autossh.service mkdir ~/.config/autostart cp clock.desktop ~/.config/autostart/clock.desktop diff --git a/ngrok.service b/ngrok.service deleted file mode 100644 index 718d5a8..0000000 --- a/ngrok.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=Start ngrok tunnel on startup -After=network-online.target -Wants=network-online.target systemd-networkd-wait-online.service - -[Service] -ExecStart=/usr/local/bin/ngrok start --all --config /home/pi/video-player/ngrok.yml -ExecReload=/bin/kill -HUP $MAINPID -KillMode=process -IgnoreSIGPIPE=true -Restart=always -RestartSec=3 -Type=simple - -[Install] -WantedBy=multi-user.target diff --git a/ngrok.yml b/ngrok.yml deleted file mode 100644 index 10a381f..0000000 --- a/ngrok.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: "2" -authtoken: 1k2wMCOOCZjQvG5SYyLqUZ0Zj2H_6JYyv1HG2GJwFJ5iGfwgi -tunnels: - web: - proto: http - addr: 8080 - domain: crawdad-deciding-wahoo.ngrok-free.app - basic_auth: - - pi:steady123