aboutsummaryrefslogtreecommitdiff
path: root/local/bin/sshvnc
blob: af133b482f8f88b330676c39fc7fe864ab3e5e08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
set -eu

target="$1"

localport="5901"
while lsof -i:$localport; do
	localport=$((localport + 1))
done

ssh -L "$localport":localhost:5900 "$target" \
	'start-stop-daemon -v -w 1000 -bmp "/var/run/user/$(id -u)/sshvnc.pid" -e WAYLAND_DISPLAY=wayland-1 -S wayvnc localhost 5900'

vncviewer "localhost:$localport"

ssh "$target" 'start-stop-daemon -v -p /var/run/user/$(id -u)/sshvnc.pid -K wayvnc'
ssh -O cancel -L "$localport":localhost:5900 "$target"