bhyve How to get x11forwarding from vm to host?

Both my host and guest are FreeBSD 15 amd64 with bhyve.I had set up the sshd and enabled X11Forwarding in /etc/ssh/ssh_config on guest. But still can't open display. How can I use X forwarding to display guest windows directly on the host?
 
Both my host and guest are FreeBSD 15 amd64 with bhyve.I had set up the sshd and enabled X11Forwarding in /etc/ssh/ssh_config on guest. But still can't open display. How can I use X forwarding to display guest windows directly on the host?
You need to enable X11Forwarding in /etc/ssh/sshd_config on your Guest.
 
Show me output of your "vm list" in your host
Show me output of your "/etc/ssh/sshd_config" in your guest
Show me output of your "ifconfig" in your guest
 
Here is my bhyve vm info:
Host OS:

# uname -v
FreeBSD 16.0-CURRENT main-n283901-0bba277f2223 GENERIC



# vm list
NAME DATASTORE LOADER CPU MEMORY VNC AUTO STATE
fbsd15 default bhyveload 2 1024M - No Running (26387)


Guest OS:

# uname -v
FreeBSD 15.0-RELEASE-p2 GENERIC



# ifconfig
vtnet0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
options=880028<VLAN_MTU,JUMBO_MTU,LINKSTATE,HWSTATS>
ether 58:9c:fc:04:94:0a
inet 10.0.0.208 netmask 0xffffff00 broadcast 10.0.0.255
inet6 fe80::5a9c:fcff:fe04:940a%vtnet0 prefixlen 64 scopeid 0x1
inet6 2601:600:4201:32b0:5a9c:fcff:fe04:940a prefixlen 64 autoconf pltime 263368 vltime 263368
media: Ethernet autoselect (10Gbase-T <full-duplex>)
status: active
nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384
options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
groups: lo
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
 
Can you even login from your host OS with ssh to your guest OS?
I can access guest with ssh.
ssh -Y root@1.1.1.1
But when I logined in,
/usr/local/bin/xauth file /root/.Xauthority does not exist
/usr/local/bin/xauth (stdin):1: bad display name "unix:10.0" in "remove" command
/usr/local/bin/xauth (stdin):2: bad display name "unix:10.0" in "add" command

and when I run
xclock,
it is
X11 connection rejected because of wrong authentication
Error: cant open display: localhost 10.0

I have
PermitRootLogin yes
X11Forwarding yes
X11DisplayOffset 10

in the /etc/ssh/sshd_config of guest.
I have not installed the vm-bhyve so I don't have the "vm list" command
 
Nevermind, I didn't pay attention to this: :confused:

"How can I use X forwarding to display guest windows directly on the host?"

I know how to test and run X apps from the guest, but not a complete DE directly from the host without using some remote desktop connection app such vnc or xrdp from from the host :confused:
 
Nevermind, I didn't pay attention to this: :confused:

"How can I use X forwarding to display guest windows directly on the host?"

I know how to test and run X apps from the guest, but not a complete DE directly from the host without using some remote desktop connection app such vnc or xrdp :(
What you want is called xdmcp, to be able to login directly on a login manager that use Xorg and that support this protocol.
 
But still can't open display.
Host needs to be running the Xserver. Keep in mind X11 applications are clients, they connect to the Xserver. So in order for X11 applications to run through X forwarding, the host (from where you are running ssh -X ...) has to have the Xserver for the X11 application to connect to.
 
my host and guest are both freebsd15amd64.
I can access guest with ssh.

ssh -Y root@1.1.1.2

When I logined in,
/usr/local/bin/xauth file /root/.Xauthority does not exist
/usr/local/bin/xauth (stdin):1: bad display name "unix:10.0" in "remove" command
/usr/local/bin/xauth (stdin):2: bad display name "unix:10.0" in "add" command

and there is a variable $DISPLAY=localhost:10.0
and when I run
xclock,
it is
X11 connection rejected because of wrong authentication
Error: cant open display: localhost 10.0

I have
PermitRootLogin yes
X11Forwarding yes
X11DisplayOffset 10

in the /etc/ssh/sshd_config of guest.
When I use the -X to access the guest, there will not a $DISPLAY variable, and can't also start display after set $DISPLAY=1.1.1.1:0 or 192.168.1.2:10 manually
 
No idea what you are doing with vm and X11, but:

In the server side, where you have the display:
1) you must run Xorg with the flag "-listen tcp"
2) You must type something like: xhost +

On the client side, where start x clients, you must give the client the name of the display to the x clients, for example to xterm with something like

# env DISPLAY=IP-ofXserver:0.0 xterm

or (not with xenocara)

# xterm -display IP-ofXserver:0.0

You DO NOT need to enable X11Forwarding in /etc/ssh/sshd_config on your Guest.
 
Assuming that you are on FreeBSD running bhyve, and both the host and guest are FreeBSD operating systems installed and configured correctly to run vm, you should be able to:
ssh -X regular_user@your.guest.vm.ip xterm
in host's console to display the "xterm" from your guest.
 
No idea what you are doing with vm and X11, but:

In the server side, where you have the display:
1) you must run Xorg with the flag "-listen tcp"
2) You must type something like: xhost +

On the client side, where start x clients, you must give the client the name of the display to the x clients, for example to xterm with something like

# env DISPLAY=IP-ofXserver:0.0 xterm

or (not with xenocara)

# xterm -display IP-ofXserver:0.0

You DO NOT need to enable X11Forwarding in /etc/ssh/sshd_config on your Guest.

No, that is an entirely different way of doing X11.

You don't need any of that when you use X11 forwarding through ssh.
 
Back
Top