From 5c391c53ce594056f900c97a2dcf454e412982d3 Mon Sep 17 00:00:00 2001 From: Michael Blaschek <michael.blaschek@univie.ac.at> Date: Mon, 18 Jan 2021 11:00:03 +0100 Subject: [PATCH] Update SSH-VPN-VNC/connect2jet.sh, SSH-VPN-VNC/README.md files --- SSH-VPN-VNC/README.md | 11 +++++++ SSH-VPN-VNC/connect2jet.sh | 64 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 SSH-VPN-VNC/connect2jet.sh diff --git a/SSH-VPN-VNC/README.md b/SSH-VPN-VNC/README.md index d49432a..e33cb64 100644 --- a/SSH-VPN-VNC/README.md +++ b/SSH-VPN-VNC/README.md @@ -27,6 +27,17 @@ The `-X` option enables X11 forwarding via ssh, i.e., permits opening graphical If you are a guest, you can apply for a [guest u:account](https://zid.univie.ac.at/uaccount/#c11096). This will give you access to eduroam and to the VPN. Your application needs to be endorsed by a staff member, who also determines the expiration date of the account. +### Connect Script +If you are using a terminal (Mac, Linux, WSL, ...) you can use the script [connect2jet.sh](connect2jet.sh) like this: +```bash +connect2jet.sh -g [U:Account-Username]@login.univie.ac.at [Jet-Username]@jet01.img.univie.ac.at +``` +There is also an option to forward a port, e.g. the VNC Port: +```bash +connect2jet.sh -g [U:Account-Username]@login.univie.ac.at -p 5901 [Jet-Username]@jet01.img.univie.ac.at +``` +which allows you to connect to `localhost:5901` and view the VNC session. Other gateway servers can be `srvx1.img.univie.ac.at` + ## VNC **Be aware! Everyone with the VNC password will get access to your account** diff --git a/SSH-VPN-VNC/connect2jet.sh b/SSH-VPN-VNC/connect2jet.sh new file mode 100644 index 0000000..5d771fa --- /dev/null +++ b/SSH-VPN-VNC/connect2jet.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# By Michael Blaschek +# Date 18.01.2021 +# CC BY 4.0 International +# University of Vienna, Austria + +# Description: +# Connect to Jet via a gateway server + +help(){ + cat << EOF +$0 -g [gateway] -p [port] user@remote +Options: + -g [gateway] gateway server, e.g. user@login.univie.ac.at + -p [port] port to forward from jet to local, egv VNC port + +Example: + $0 -g [U:Account-Username]@login.univie.ac.at [Jet-Username]@jet01.img.univie.ac.at + +EOF +} + +while getopts "g:p:h" flag; +do + case "${flag}" in + g ) gateway=${OPTARG}; ;; + p ) port=${OPTARG}; ;; + h|* ) help; exit 0;; + esac +done +shift $((OPTIND-1)) +command="" +remote=$1 +script=$(basename $0) + +if [ "${remote}" == "" ]; then + echo "Remote host required: [user]@[server]" + help + exit 1 +fi + +if [ -n "${port}" ]; then + echo "Forwarding Port: $port" + command="-L ${port}:localhost:${port} " +fi + +if [ -n "${gateway}" ]; then + echo "$gateway" | grep '@' > /dev/null + if [ $? -eq 1 ]; then + echo "Please give: [user]@[server], not $gateway" + exit 1 + else + echo "Using gateway: $gateway to $remote " + ssh $command -t $gateway 'ssh ${command} ${remote}' + echo "$(date) | ssh $command -t $gateway 'ssh ${command} ${remote}'" >> .${script/.sh/.log} + fi +else + echo "Direct connection to: ${remote}" + ssh ${command} ${remote} + echo "$(date) | ssh ${command} ${remote}" >> .${script/.sh/.log} +fi +echo "Command Log in .${script/.sh/.log}" + + -- GitLab