Commit aa6ec008 authored by Mathis Rosenhauer's avatar Mathis Rosenhauer

start-vnc: use random local port because of WSL

parent 7f5c3702
......@@ -288,13 +288,18 @@ main () {
echo "Vncserver started on node ${vnc_host}.dkrz.de display \
:${vnc_display}."
local vnc_port=$((5900+${vnc_display}))
ssh -o ForwardX11=no \
-o StrictHostKeyChecking=accept-new \
-L "${vnc_port}:localhost:${vnc_port}" \
-Nf \
"${SVNC_USERNAME}@${vnc_host}.dkrz.de";
local vnc_port_local=$((5900 + RANDOM % 100))
# WSL doesn't seem to detect used ports so randomize
# local port to reduce risk of masking.
local vnc_port_remote=$(( 5900 + vnc_display ))
while ! ssh -o ForwardX11=no \
-o StrictHostKeyChecking=accept-new \
-L "${vnc_port_local}:localhost:${vnc_port_remote}" \
-Nf \
"${SVNC_USERNAME}@${vnc_host}.dkrz.de"; do
vnc_port_local=$((5900 + RANDOM % 100))
echo "Trying local port ${vnc_port_local}."
done
local client_options
client_options="${SVNC_CLIENT_OPTIONS:-}"
if [[ ${SVNC_PASSWORD} = "true" ]]; then
......@@ -303,7 +308,7 @@ main () {
client_options+=" -passwd vnc_passwd"
fi
echo "Connecting vncviewer to ${vnc_host}.dkrz.de"
"${SVNC_CLIENT}" ${client_options} :${vnc_display}
"${SVNC_CLIENT}" ${client_options} :$(( vnc_port_local - 5900 ))
}
main "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment