Skip to content
Snippets Groups Projects
Commit 8496a35c authored by Mathis Rosenhauer's avatar Mathis Rosenhauer
Browse files

Use ssh multiplexing

parent b1cdd18e
No related branches found
No related tags found
No related merge requests found
......@@ -14,8 +14,9 @@
# The vncviewer client has to support the -via option. TurboVNC,
# TigerVNC and TightVNC are known to work.
#
# You really should use publickey authentication. Otherwise you
# have to type your password many times.
# Set SSH_MUX=true to share one ssh connection. This can speed up the
# script if ssh login is slow. If you have to use password
# authentication, you will only have to give your password twice.
set -e
......@@ -28,8 +29,9 @@ readonly GEOMETRY="1920x1200" # resolution of remote desktop window
readonly VNCVIEWER=/usr/bin/vncviewer # path to local vncviewer
readonly PASSWORD=true # copy vncpassword temporarily to
# the local workstation
#readonly OPTIONS="-extssh" # uncomment this if you use
readonly SSH_MUX=true # use sharing of multiple ssh sessions
# over a single network connection
#readonly OPTIONS="-extssh" # uncomment this if you use
# TurboVNC as vncviewer
clean_up () {
......@@ -55,6 +57,10 @@ clean_up () {
${ssh_mistral} "cd .startvnc && rm -f ${tmp_files}"
fi
if [[ ${SSH_MUX} = true ]]; then
ssh ${ssh_options} -O exit ${mistral}
fi
# Remove local vnc PasswordFile
if [[ ${copy_password} = true ]]; then
rm -f ${HOME}/vnc_passwd
......@@ -83,7 +89,7 @@ do
;;
v) vncviewer="$OPTARG"
;;
x) options="$OPTARG"
x) vnc_options="$OPTARG"
;;
?) usage
exit 2
......@@ -97,10 +103,15 @@ qos=${qos:-${QOS}}
runtime=${runtime:-${TIME}}
username=${username:-${USERNAME}}
vncviewer=${vncviewer:-${VNCVIEWER}}
options=${options:-${OPTIONS}}
mistral="${username}@mistral.dkrz.de"
ssh_mistral_options="-x"
ssh_mistral="ssh ${ssh_mistral_options} ${mistral}"
vnc_options=${vnc_options:-${OPTIONS}}
mistral="${username}@mistral00.dkrz.de"
ssh_options="-o ForwardX11=no"
if [[ ${SSH_MUX} = true ]]; then
ssh_options+=" -o ControlPath=~/.ssh/control:%h:%p:%r"
fi
ssh_mistral="ssh ${ssh_options} ${mistral}"
if [[ -z ${acctcode} ]] || [[ -z ${username} ]]; then
printf "ERROR: Please specify at least username and acctcode.\n\n" >&2
......@@ -108,6 +119,10 @@ if [[ -z ${acctcode} ]] || [[ -z ${username} ]]; then
exit 2
fi
if [[ ${SSH_MUX} = true ]]; then
ssh -MNf ${ssh_options} ${mistral}
fi
if ! ${ssh_mistral} "test -s .vnc/passwd"; then
echo "No VNC password found. Please set now."
${ssh_mistral} -t "salloc -Q -n1 -pgpu -A${acctcode} -- /bin/bash -c \
......@@ -154,12 +169,12 @@ host_and_display=$(${ssh_mistral} "/bin/bash .startvnc/gethost.${job_id}")
vnc_host=${host_and_display%:*}
vnc_display=${host_and_display#*:}
options+=" -via ${username}@${vnc_host}.dkrz.de"
vnc_options+=" -via ${username}@${vnc_host}.dkrz.de"
if [[ ${PASSWORD} = true ]]; then
scp -q -o "ForwardX11=no" ${mistral}:.vnc/passwd ${HOME}/vnc_passwd
options+=" -passwd ${HOME}/vnc_passwd"
scp -q ${ssh_options} ${mistral}:.vnc/passwd ${HOME}/vnc_passwd
vnc_options+=" -passwd ${HOME}/vnc_passwd"
fi
# Start VNC viewer
${vncviewer} ${options} :${vnc_display}
${vncviewer} ${vnc_options} :${vnc_display}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment