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

target="$1"

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

ssh -L "$localport":localhost:5901 "$target" \
	'systemctl --user start wayvnc1.service'

vncviewer "localhost:$localport"

ssh "$target" 'systemctl --user stop wayvnc1.service'
ssh -O cancel -L "$localport":localhost:5901 "$target"