cockpit-machines icon indicating copy to clipboard operation
cockpit-machines copied to clipboard

desktop console show wrong ip address

Open Ludo-code opened this issue 1 year ago • 13 comments

Hello, the desktop console in cockpit-machine doesn't show the good address.... he show 127.0.0.1 image So my cockpit is proxied over apache2 if this can help... anyone know how to have the good address ?

Ludo-code avatar May 15 '23 13:05 Ludo-code

Hello. Did you used cockpit's functionality of adding new host? Screenshot from 2023-05-16 14-14-27

If so, then this issue is probably the same as the https://github.com/cockpit-project/cockpit-machines/issues/64 Can you confirm that it's the same bug?

skobyda avatar May 16 '23 12:05 skobyda

Hello I don't use this fonctionnality to add other host...

Ludo-code avatar May 16 '23 12:05 Ludo-code

Is this the setup you use? https://evermeet.cx/wiki/Reverse_Proxy_setup_for_Cockpit_with_Apache_(in_a_sub_directory)

Anyway as a workaround, you could try to edit console address. You can achieve that with command virsh edit [vm name] Then find the element and changing the address there.

Please let me know if that helps

skobyda avatar May 17 '23 08:05 skobyda

no i have followed this one : https://github.com/cockpit-project/cockpit/wiki/Proxying-Cockpit-over-Apache-with-LetsEncrypt

i try with virsh this afternoon.

Ludo-code avatar May 17 '23 09:05 Ludo-code

I'm able to reproduce. I do not use any exotic Cockpit / Cockpit-machines setting, see below:

image

I'm not sure whether this is expected, since Libivrt/QEMU is running on the local host. If running on a Linux Distro, with desktop environment, it will happily show you 127.0.0.1. Except that will work since you can use a graphic program (e.g. Spice Space) to connect to the machines over your loopback IP.

You should be able to connect via your Servers IP on port 5901 for Spice or 5900 for VNC. Note: you need to create an allow rule in the firewall. I think this actually can be replaced with the server IP. Alternatively it could also also be changed to something like: loopback / server_IP.

Imo this would make things a bit more clear for new(er) users :).

Larse99 avatar May 18 '23 08:05 Larse99

Hello, how can i proceed to do this with the firewall?

Ludo-code avatar May 18 '23 14:05 Ludo-code

Hello, how can i proceed to do this with the firewall?

Depends on your distro. You could use iptables/nftables entries. On Rocky, CentOS, Fedora and derivatives I often find myself using:

sudo firewall-cmd --add-port=5900/tcp --permanent sudo firewall-cmd --add-port=5901/tcp --permanent sudo firewall-cmd --reload

This will add the ports to your default zone, which is most of the time the "public" zone.

Larse99 avatar May 19 '23 06:05 Larse99

I'm on ubuntu server and the default firewall ufw is disabled. Anyway me I use a physical firewall so I think I must enable the default one?

Ludo-code avatar May 19 '23 09:05 Ludo-code

The loopback address is from VM's configuration. And since VM is located on the server, then from the VM's point of view the VNC server is located on localhost. But of course, when you download a .vv file through cockpit, you are spawning it on client and VNC server is located at your server IP, not localhost. But the reason why we used VM's IP address until now is that it's configurable, and user can specify a custom IP where VNC server is running. So maybe Cockpit should do the following:

Check VNC IP address in VM'x configuration. If IP address is different from localhost, use that IP address. If IP address is the same as localhost, use server's IP address.

@Ludo-code do you think that would solve your problem?

skobyda avatar May 22 '23 08:05 skobyda

yes thanks you :)

Ludo-code avatar May 24 '23 04:05 Ludo-code

Hmm, so here I proposed a solution to allow VNC server to listen an all interfaces, not just loop back. But that may be a security issue, if user doesn't have some verifications (e.g. tls) setup, otherwise that leaves an open port with access to VM's VNC.' So maybe a better solution is to allow a user to set up a port-forwarding to their localhost, so then a downloaded .vv file can just open VNC by connecting to a localhost port, which is then forwarded to a remote server where VM is locatd.

@Ludo-code in your example as shown in https://github.com/cockpit-project/cockpit-machines/issues/1078#issue-1710154468, it would be an equivalent to running this on client:

ssh -L 5900:localhost:5900 -N -l remoteuser remoteserveraddress

Then downloading a .vv file and opening it should show a VNC console. That should also work for you as a workaround until we fix it, does that work for you?

skobyda avatar May 24 '23 08:05 skobyda

Related, a discussion about the VNC / SPICE config in Cockpit-machines:

  • #553

(This is more for a redesign for the UI and how it would work.)

garrett avatar Jun 12 '23 14:06 garrett

FYI there is a work around for this: See issue #73

madwax avatar Aug 13 '23 18:08 madwax