Skip to content

Add VNC video display including password #1004

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

Merged
merged 4 commits into from
Feb 11, 2023
Merged

Conversation

afbjorklund
Copy link
Member

@afbjorklund afbjorklund commented Jul 31, 2022

The other display options open a window always, while the
vnc is more "on demand" by using a separate vnc viewer.

Add localhost and password support for some minimal security.
The password is generated, and is stored as an instance file.

Closes #1003

@afbjorklund afbjorklund marked this pull request as draft July 31, 2022 17:45
@afbjorklund afbjorklund changed the title Add VNC video display including websockets Add VNC video display including password Aug 3, 2022
@afbjorklund
Copy link
Member Author

Probably should move the display of the password, or perhaps just show the filename ?

INFO[0000] [hostagent] Starting QEMU (hint: to watch the boot progress, see "/home/anders/.lima/default/serial.log") 
INFO[0001] [hostagent] VNC Password for 127.0.0.1:0 is: 17791850 
INFO[0001] SSH Local Port: 60022                        
INFO[0001] [hostagent] Waiting for the essential requirement 1 of 5: "ssh" 

Some viewers accept a passwordfile, rather than prompting for the (clear-text) password.

@afbjorklund
Copy link
Member Author

afbjorklund commented Aug 3, 2022

Oops, forgot to seed the random number generator so the generated "password" is always the same.

https://pkg.go.dev/math/rand

@afbjorklund
Copy link
Member Author

Should show a real URL, so that it is clickable in the console (maybe include the VNC password too?)

The current output works in vncviewer:

127.0.0.1:0 <--> vnc://127.0.0.1:5900

https://tools.ietf.org/html/rfc7869

@afbjorklund
Copy link
Member Author

afbjorklund commented Oct 2, 2022

INFO[0000] [hostagent] VNC Password for 127.0.0.1:0 <vnc://127.0.0.1:5900> is: 
INFO[0000] [hostagent]     "46479782" | `/home/anders/.lima/default/vncpassword` 

Note that the default user doesn't have any password, so still needs passwd for console.


gvncviewer 127.0.0.1:0

gvncviewer-lima

novnc 127.0.0.1:0 (https://novnc.com/)

Using installed websockify at /snap/novnc/8/bin/websockify
Starting webserver and WebSockets proxy on port 6080
WebSocket server settings:
  - Listen on :6080
  - Web server. Web root: /snap/novnc/8
  - No SSL/TLS support (no cert file)
  - proxying from :6080 to localhost:5900


Navigate to this URL:

    http://ubuntu:6080/vnc.html?host=ubuntu&port=6080

Press Ctrl-C to exit

@afbjorklund afbjorklund marked this pull request as ready for review October 2, 2022 19:49
@jandubois
Copy link
Member

Note that the default user doesn't have any password, so still needs passwd for console.

So this works great to get the console, but how do you log in?

@jandubois
Copy link
Member

Note that the default user doesn't have any password, so still needs passwd for console.

So this works great to get the console, but how do you log in?

Sorry, was confused; I just realized that this is exactly the same as the regular console 😄

@afbjorklund
Copy link
Member Author

afbjorklund commented Oct 9, 2022

So this works great to get the console, but how do you log in?

It also depends on the example, and if you add a login manager you could also add more login methods ?

The VNC "password" is just to protect the display as such, it doesn't change anything about authentication

Otherwise it is no different from any other qemu -display option.

@afbjorklund

This comment was marked as outdated.

@afbjorklund

This comment was marked as outdated.

@afbjorklund afbjorklund force-pushed the vnc branch 2 times, most recently from 507e2bc to 03e9367 Compare October 16, 2022 12:07
@afbjorklund
Copy link
Member Author

afbjorklund commented Oct 16, 2022

Now the default vnc display will pick the first available one, from 127.0.0.1:0 127.0.0.1:1 ... 127.0.0.1:9

This means that all the user needs to to do is to change the display type from "none" to "vnc", and get the password.

It can either be seen in the log, or read from the instance file.

The log will also show the display number, if it wasn't fixed.


Maybe the display needs a separate file, next to the password.

Then you could just read the vncdisplay file, for the address ?

@AkihiroSuda
Copy link
Member

Then you could just read the vncdisplay file, for the address ?

SGTM.
Maybe we can also have limactl show-vnc (akin to limactl show-ssh) to show the VNC info.

Btw, I guess the VNC feature should be marked as an experimental for now, at least until we can have integration tests (how?)?

@AkihiroSuda AkihiroSuda added this to the v0.14 (tentative) milestone Oct 19, 2022
@AkihiroSuda
Copy link
Member

CI failing

@afbjorklund
Copy link
Member Author

Btw, I guess the VNC feature should be marked as an experimental for now, at least until we can have integration tests (how?)?

I couldn't really find any integration tests for the other display settings either, except for the default of none I guess.

@afbjorklund
Copy link
Member Author

Just because I said that, I actually managed to break "default" in the latest re-design (when moving to Video.Display)

"level":"fatal","msg":"Could not set password"

oops.

@afbjorklund
Copy link
Member Author

Broken by the driver introduction

@afbjorklund
Copy link
Member Author

afbjorklund commented Nov 16, 2022

Added some new functions to the BaseDriver, need to verify that it is QEMU before allowing VNC...

      ChangeDisplayPassword(_ context.Context, password string) error

      GetDisplayConnection(_ context.Context) (string, error)

"port" seemed a little specific, so went with a more generic "connection" (even if only vnc uses it)

@afbjorklund afbjorklund marked this pull request as draft November 16, 2022 19:40
@afbjorklund afbjorklund marked this pull request as ready for review November 16, 2022 20:31
@AkihiroSuda AkihiroSuda modified the milestones: v0.14, v0.15 (tentative) Nov 25, 2022
@AkihiroSuda
Copy link
Member

Needs rebase

@afbjorklund
Copy link
Member Author

afbjorklund commented Feb 11, 2023

The other display options open a window always, while the
vnc is more "on demand" by using a separate vnc viewer.

Add localhost and password support for some minimal security.
The password is generated, and is stored as an instance file.

Signed-off-by: Anders F Björklund <[email protected]>
It makes sure to use crypto/rand instead of math/rand.

Also includes all the characters, and not just digits.

Signed-off-by: Anders F Björklund <[email protected]>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 5491b37 into lima-vm:master Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for VNC, in addition to the current QEMU displays
3 participants