40 lines
1.3 KiB
Bash
40 lines
1.3 KiB
Bash
|
#!/bin/bash
|
||
|
# This starts a VNC-Server with the current users X11-Desktop piped through SSH
|
||
|
|
||
|
. /etc/bash/gaboshlib.include
|
||
|
|
||
|
userathost="$1"
|
||
|
port="$2"
|
||
|
|
||
|
function usage {
|
||
|
g_echo_error_exit "USAGE: $0 USER@HOST PORT"
|
||
|
}
|
||
|
|
||
|
[ -z $userathost ] && usage
|
||
|
[ -z $port ] && usage
|
||
|
|
||
|
sshopts="-p $port -o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new -o LogLevel=ERROR -o PreferredAuthentications=publickey $userathost"
|
||
|
|
||
|
g_echo "Testing SSH-Connection"
|
||
|
ssh $sshopts >/dev/null 2>&1
|
||
|
if [ $? == 255 ];then
|
||
|
g_echo_error "SSH-Verbindung konnte nicht aufgebaut werden!"
|
||
|
if ! [ -e ~/.ssh/id_ed25519.pub ]
|
||
|
then
|
||
|
g_echo "Erstelle SSH-PublicKey"
|
||
|
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N "" -q
|
||
|
fi
|
||
|
g_echo "Bitte dem Admin des Zielservers folgenden PublicKey mitteilen:"
|
||
|
cat ~/.ssh/id_ed25519.pub
|
||
|
echo "Zum Beenden Enter/Return drücken"
|
||
|
read x
|
||
|
exit 255
|
||
|
fi
|
||
|
|
||
|
|
||
|
tmux new -s x11vnc2ssh \
|
||
|
'echo "Dienst gestartet! Zum Beenden Enter/Return drücken"; read x ; tmux kill-session -t x11vnc2ssh' \; select-layout even-vertical\; \
|
||
|
split-window -d "set -x ; ssh -N -o RemoteForward=\"5900 localhost:5900\" $sshopts; read x" \; select-layout even-vertical \; \
|
||
|
split-window -d 'set -x ; x11vnc -q -nopw -auth guess -forever -loop -noxdamage -nomodtweak -noxkb -repeat -rfbport 5900 -shared -localhost ; read x' \; select-layout even-vertical
|
||
|
|