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

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"