3

My host system is Win 11 Pro with Hyper-V enabled, also using "Enhanced session mode".

I have a few Ubuntu versions installed manually (I downloaded the ISO and ran install), but they always have issues. So this time I used Quick Create and the latest long term support version of Ubuntu (22.04). I hoped it would work better because it was curated.

And it connects just fine when I launch it from Hyper-V Manager. It uses the XRDP protocol with an Xorg session. Wow!

Now, on all my manually installed Ubuntu VMs, I have never seen that XRDP screen when launching from Hyper-V Manager. I only see it when I try to connect from Remote Desktop. So I assumed this time it's working better than usual.

But when I try to connect from Remote Desktop, I get the error "Remote Desktop can't connect to the remote computer".

I have Googled my butt off, tried lots of seemingly pointless things, and proven those things were pointless. Nothing I've tried so far has made a difference.

For the "Computer" field of Remote Desktop, I tried using the actual computer name, the IPV4 address, and the IPV6 address. Nothing worked.

But... I can ping from host to guest, and from guest to host.

XRDP is obviously installed in the guest Ubuntu system.

I have no idea what's causing it to not connect.

3 Answers3

1

I have one computer with VMware and the other with Hyper-V. The Hyper-V system has both Ubuntu and Kali Guests and I can connect to both of them from the first computer using RDP.

XRDP is obviously installed in the guest Ubuntu system.

(1) That is good (necessary).

Make sure now that XRDP is enabled. sudo systemctl enable xrdp

Then make sure XRDP has been started. sudo systemctl start xrdp

You may wish to check the XRDP status to ensure it is running.

(2) Good idea (best) to give the Ubuntu Guest in Hyper-V an External Switch (Bridged network in most VM apps). This is so RDP on the other computer can readily find the Ubuntu Guest.

Close down the Guest, make a New External Switch in Hyper-V. Go to the Guest settings in Hyper-V and select the External Switch.

Start the Guest and make sure the External Switch is working.

(3) Restart the Guest, start the XRDP service (needs to be restarted with every Linux restart.

Now log off Linux but leave it running.

Go to your other machine and RDP in. Should work. Steps above work flawlessly for me.

John
  • 46,167
  • 4
  • 33
  • 54
  • I checked first, and XRDP was both enabled and actively running. But I still ran your commands just in case. I was already using an external switch named after my sole NIC: a Killer E3200G 2.5 GB Ethernet Controller. I currently have 6 Ubuntu based VMs. To confirm how things work, I tried starting each one from Hyper-V Manager and from a Remote Desktop connection. The results were different than I expected. – Bobby Cottle Mar 12 '23 at 01:22
  • 5 of them would only start via Hyper-V Manager (but using the XRDP login screen, meaning I am forced to log in before I get to see the Ubuntu screen). Only 1 of them would let me log in via the RDP screen (and for Hyper-V present the direct Ubuntu login screen). EVERY VM uses the external switch. I don't know what's wrong. – Bobby Cottle Mar 12 '23 at 01:22
  • You need to start your Ubuntu machine, start XRDP, and then log off, but do not shut down. Now from your other or host machine, RDP should work . I have tested all that I wrote and have it working. – John Mar 12 '23 at 01:29
  • Also in testing here, one machine had to be restarted after I closed the active, working RDP Session. No big deal. Try: (1) On a guest make sure XRDP is all set up and working. Shut down the guest. Restart the host. Start up the Guest, start XRDP, log off, and try RDP from the Host. I am doing this - I know it works. Also make sure the Guest and Host are fully up to date. – John Mar 12 '23 at 01:42
  • When I start the Ubuntu VM via Hyper-V Manager, I'm obviously logged in. If I click log out, the XRDP connection terminates (it will not let me stay connected if I'm not logged in). If I then try to connect via Remote Desktop, it always says it cannot find the VM. No matter if I use computername, computername.local, or its IP address. – Bobby Cottle Mar 12 '23 at 01:44
  • First comment: Logging out of Ubuntu or Kali does NOT kill XRDP. Something wrong there. Second comment: Suggests your External Switch is not set up correctly / working correctly. No issue finding a machine on the same LAN with a proper LAN address. Try deleting and setting up the External Switch again. – John Mar 12 '23 at 01:47
  • I get what you're saying: on that one VM that works with RDP, I can actually see the Ubuntu login screen when I connect via Hyper-V Manager. And logging out does not kill the connection. I think I may have screwed up some setting via Power Shell, or maybe a Win11 update introduced chaos. I'm at my wit's end. – Bobby Cottle Mar 12 '23 at 01:49
  • Your most recent comment (one VM works) confirms all I am saying. – John Mar 12 '23 at 01:50
  • I deleted the external Virtual Switch, then created a new one. I edited settings for a VM to use this new switch, then started it so it would boot up to the login screen. (You can see the thumbnail at the bottom of Hyper-V Manager.) I tried to connect via RDP shortcut - cannot find computer. Tried connecting via Hyper-V Mgr, it shows the XRDP login screen. So no change at all. – Bobby Cottle Mar 12 '23 at 01:55
  • I am not sure what is wrong with your setup. I have lashed RDP to Hyper-V VMs several times – John Mar 12 '23 at 01:57
  • I know it's _supposed_ to work the way you say. I remember that several of them _used_ to work that way. But only one of them works that way now. I don't know how to find out what's actually wrong. – Bobby Cottle Mar 12 '23 at 01:58
1

This is what seems to be working for me...

First, I had to disable "Allow enhanced session mode" in the Hyper-V settings. That may actually be the only thing required, but the next step is kinda neat, so...

I edited /etc/xrdp/xrdp.ini to have multiple values for PORT:
port=vsock://-1:3389 tcp://:3389

This lets me connect by RDP as well as Hyper-V Manager at the same time! I think you can log in to separate accounts, but trying to have two logins to the same account will fail.

Got that suggestion from https://github.com/neutrinolabs/xrdp/issues/1260.

I'm not really happy with this workaround, but maybe that's just pessimism. If anyone has a better working suggestion I'll be happy to credit them.

-1

After (also) "... Googl[ing] my butt off..." and trying a ton of things, I found that Ubuntu 22.04 now has native support for Microsoft RDP.

All I had to do was go into the Ubuntu vm's Settings, and under Sharing turn on Remote Desktop and enable Remote Control. Ba da boom! It finally worked!

Pictures in this article: Ubuntu 22.04 Finally Supports Remote Desktop Control via MS RDP Protocol | UbuntuHandbook

[Now, I'm just not sure what I've broken by trying all those other things ;)]


Update: Not sure why the downvote; however... upon creating a new VM and following just these steps, this didn't work - so one of the many other things I tried might've solved it. I have some thoughts, so I'll update this answer once I've found the "key"... (or delete it if I don't find the key shortly)

leanne
  • 571
  • 5
  • 11