-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add command to request a VNC console #238
Conversation
Bump. Rebased onto latest master. The commit for the version bump for the hcloud library is now gone. This is still good to go from my side. |
Hey @minus7, first of all thank you for the MR. We tried it out locally (the proxy option) and on our machines (tested on MacOS and Linux) the VNC connection does not work. I would prefer to not let the cli proxy the connection, it should just "output" the data. |
Do you have more info on why it doesn't work? I run
If you don't specify |
We (@fhofherr on Linux and i on MacOS) tested it the same way:
As you can see, adding a proxy is mostly not that easy so i would still favor to not have the proxy itself in the hcloud cli. The cli should be as small as possible. |
I guess your VNC client connects twice and the proxy exits after the first connection disconnects. I'll remove the proxy commit then if I can't convince you to take it :) |
It would be good if you could add the -o flag (have a look at the list endpoints) with json, so basically output it as json :) |
Proxy mode is gone now and JSON added |
Thank you! Will be available with the next release version. |
I would have preferred if the proxy option would have been merged, but OK ... FTR: connecting to the websocket URL is possible via websocat
You have to make sure to enclose the websocket URL in single-quotes A one-liner of this (with some limitations like only 1 parallel instance) is
Then connect with your preferred VNC client to |
I wrapped that up in a shell script for ease of use: #!/bin/bash
j=$(hcloud server request-console -o json "$1")
url=$(echo "$j" | jq -r '.WSSURL')
password=$(echo "$j" | jq -r '.Password')
tmpdir="$(mktemp -d ${XDG_RUNTIME_DIR:-/tmp}/hcloud-vnc.XXXXXXXXXX)"
trap 'rm -rf "$tmpdir"' EXIT
websocat --oneshot --binary unix-listen:"$tmpdir/vnc.sock" "$url" &
VNC_PASSWORD=$password vncviewer "$tmpdir/vnc.sock"
wait |
Add command to request a VNC console.
Also includes a proxy translating WebSocket to a normal TCP socket using the(script for that below)-l
flag. This allows a normal VNC viewer to connect to the console by connecting to localhost:5900.This also updates the version of the hcloud library to make use of the console API added in hetznercloud/hcloud-go#134
Preview: