From ba75001d31e0cce3dd2b2875760704224d0ded40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Mon, 4 Jan 2021 21:45:04 +0100 Subject: Add sshvnc --- install | 1 + local/bin/sshvnc | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100755 local/bin/sshvnc diff --git a/install b/install index 5ceda46..0512423 100755 --- a/install +++ b/install @@ -35,6 +35,7 @@ fi if ask "ssh" "Install SSH config"; then inst private/ssh_config ~/.ssh/config + inst local/bin/sshvnc ~/.local/bin/sshvnc fi if ask "vim" "Install VIM scripts"; then 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" -- cgit v1.2.3