aboutsummaryrefslogtreecommitdiff
path: root/local/bin/sshvnc
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2021-01-04 21:45:04 +0100
committerKarel Kočí <cynerd@email.cz>2021-01-04 21:45:04 +0100
commitba75001d31e0cce3dd2b2875760704224d0ded40 (patch)
tree177496d7fccc1d425961b57e2fc5f19d8c304db5 /local/bin/sshvnc
parent3592f266671db42a382b406d044146782905cde7 (diff)
downloadmyconfigs-ba75001d31e0cce3dd2b2875760704224d0ded40.tar.gz
myconfigs-ba75001d31e0cce3dd2b2875760704224d0ded40.tar.bz2
myconfigs-ba75001d31e0cce3dd2b2875760704224d0ded40.zip
Add sshvnc
Diffstat (limited to 'local/bin/sshvnc')
-rwxr-xr-xlocal/bin/sshvnc17
1 files changed, 17 insertions, 0 deletions
diff --git a/local/bin/sshvnc b/local/bin/sshvnc
new file mode 100755
index 0000000..8b6fa0d
--- /dev/null
+++ b/local/bin/sshvnc
@@ -0,0 +1,17 @@
+#!/bin/bash
+set -eu
+
+target="$1"
+
+localport="5901"
+while lsof -i:$localport; do
+ localport=$((localport + 1))
+done
+
+ssh -L "$localport":localhost:5900 "$target" \
+ 'x11vnc -bg -localhost -display :0'
+
+vncviewer "localhost:$localport"
+
+ssh "$target" 'x11vnc -remote stop -localhost -display :0'
+ssh -O cancel -L "$localport":localhost:5900 "$target"