How to use x11vnc to login to graphical desktop?

New to Debian (Or Linux in general)? Ask your questions here!

How to use x11vnc to login to graphical desktop?

Postby mangoduck » 2021-02-07 23:36

I have a fresh install of Debian with XFCE on a desktop. I would like to be able to disconnect my monitor from this desktop permanently, and use x11vnc to connect to it on the rare occasion I need to use the graphical desktop. The problem is that x11vnc cannot find an X display, unless I have a monitor connected and use it to log in first. I've tried starting an X session of some kind (via ssh), but I haven't been able to figure out exactly what that means or how to do it, and I always run into "Only console users are allowed to run the X server".

I've been all over the net, trying to piece together the knowledge to do what I want from snippets of code and vaguely related forum posts, but it is beyond me. It's also difficult to piece together how people have gotten this to work before, because they include all kinds of unnecessary steps (like setting up x11vnc with a password, or tunneling it through ssh, or setting up x11vnc as a service) without really explaining which parts are supposed to do something unrelated, and which parts are supposed to help use x11vnc from the login screen. I don't blame them, because they created the various forum posts to answer different questions than I have, but it has made it difficult for me to orient myself.

So, please, if I have a desktop with no monitor, ssh access to said desktop with the ability to start x11vnc and tunnel it through ssh, and a vnc viewer that definitely works with x11vnc (in the case that I can login first)... What do I need to do so that I can remotely login and use the graphical desktop using ssh and x11vnc?

To clarify and reiterate, I don't need help automatically starting x11vnc on bootup; I can do it manually or automate it myself, once I know what to do. I just need to know how to get x11vnc to work at the login screen, without a monitor, and without having logged in first.

I'm a linux beginner, but not completely ignorant. All help is appreciated, but it'd be fantastic if you could explain any answers a bit so I know what exactly I'd be doing if I follow your advice. Thank you in advance.
mangoduck
 
Posts: 2
Joined: 2021-02-07 04:11

Re: How to use x11vnc to login to graphical desktop?

Postby Head_on_a_Stick » 2021-02-08 10:21

Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 13450
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: How to use x11vnc to login to graphical desktop?

Postby trinidad » 2021-02-08 11:45

I used to do this to save space on my desk. (one less monitor) The easiest thing to do is to set the host (the machine without a monitor) to auto-login (so its user interface and x are available) Hopefully you originally installed the system with a monitor attached. It must also have ssh server and x11vnc server on it. Then you just need to login to it from your client with ssh and start its x11vnc server (you can alias that command string in advance on the host to make things easier) then connect via Remmina. The tutorial below should be helpful. Read sections 3,4 & 5b. If you are on wayland on the client you may either need xephyr or select Xorg from the gdm login screen. I'm not sure about xwayland displaying from x11vnc inputs without spice connections. If you are only using a few specific programs on the host ssh x forwarding may work better for you.

https://www.dbts-analytics.com/ll4ntw1.html

TC
You can't believe your eyes if your imagination is out of focus.
trinidad
 
Posts: 167
Joined: 2016-08-04 14:58

Re: How to use x11vnc to login to graphical desktop?

Postby jb_11000 » 2021-02-08 14:57

Maybe you could try configuring your vnc server to run on display :1 ? As far as I can remember, display :0 is reserved for the main display manager, so if this is not running then you won't be able to initialise the vnc server on it or remote into it.

I use TigerVNC so I don't know how far this will apply to you - please take it as a pointer in the right direction rather than a solution!

First I had to create a .sh script in ~/.vnc called xstartup with the following lines:

#!/bin/sh
xrdb $HOME/.Xresources
vncconfig -iconic &
dbus-launch --exit-with-session xfce4-session &

This script configures and launches an instance of the desktop environment which runs in the background. It is run when I initialise my vnc server - the :1 tells it to use display :1 - with the following command:

vncserver :1 -localhost -geometry 1920x1080 -depth 32

This way I can remote desktop into the server, while if I switch on the TV connected to the server, it still only shows the console. I still need to ssh into the server beforehand to run the command, so if you're looking to bypass that and have the vnc server run automatically on startup, then you will need to put the command in a script which runs at startup - and as I'm a beginner myself I won't try to tell you the correct way to do that, but I'm sure a quick search for "run linux script at startup" would get you started. I managed to get mine working successfully just through googling so persevere!
jb_11000
 
Posts: 7
Joined: 2021-02-05 16:08

Re: How to use x11vnc to login to graphical desktop?

Postby themagicm » 2021-02-08 18:27

Here you go.
https://linuxize.com/post/how-to-instal ... debian-10/

I'm doing what you're basically asking. I have a few deb 10 VMs running on a r710 and all I do is use Remmina to connect.

Enjoy..
themagicm
 
Posts: 48
Joined: 2011-11-23 06:08

Re: How to use x11vnc to login to graphical desktop?

Postby mangoduck » 2021-02-08 21:43

Head_on_a_Stick wrote:https://wiki.archlinux.org/index.php/x11vnc#SSH_Tunnel

Thank you for your reply, but as I explained in my post, I don't need help with SSH.

trinidad wrote:I used to do this to save space on my desk. (one less monitor) The easiest thing to do is to set the host (the machine without a monitor) to auto-login (so its user interface and x are available)

Thanks, but I'd rather not leave my machine vulnerable by having it automatically log in.

jb_11000 wrote:First I had to create a .sh script in ~/.vnc called xstartup with the following lines:

#!/bin/sh
xrdb $HOME/.Xresources
vncconfig -iconic &
dbus-launch --exit-with-session xfce4-session &

This script configures and launches an instance of the desktop environment which runs in the background. It is run when I initialise my vnc server - the :1 tells it to use display :1 - with the following command:

vncserver :1 -localhost -geometry 1920x1080 -depth 32

Thanks so much! I've seen references to the xstartup script, but I can't find any documentation on it. Just having a script doesn't do anything; what calls the script? And when?

When I man xrdb, it appears that it sets properties for x clients to use based on the passed file. I don't have a .Xresources file in my home directory, though. What needs to be in it? What format do I use to specify the properties? Where did you get your .Xresources file from? What all needs to be in it?

I do not have a vncconfig command; I think that's TigerVNC specific.

When I try to run the xfce4-session command, or the dbus-launch command that runs the xfce4-session command, I get the following error:
Code: Select all
xfce4-session: Cannot open display: .

I couldn't glean much from the man page for xfce4-session. It seems that by saying "display: ." it was expecting the number of a display, but received an empty string somehow. I wonder if I had been able to run xrdb first, if that would have set an environmental variable that the xfce4-session could use to find an actual display.

I'm familiar how to specify which display x11vnc uses, and have tried :0 and :1 and the -find option, but the problem is there doesn't appear to be ANY displays for it to use. I think the xstartup script, and the .Xresources file are the key, but I'm having trouble finding info. I found this info about the xrdb command with a description of how to construct an .Xresources file: https://www.computerhope.com/unix/uxrdb.htm, but I'm still not sure what I would need to put into my own .Xresources file to make it work. Could you post the contents of yours?


Thanks for your response. That's a different server, and an entirely different protocol than I would like to use. I'm hoping to get this working with x11vnc, which others have done, but haven't documented how exactly.
mangoduck
 
Posts: 2
Joined: 2021-02-07 04:11

Re: How to use x11vnc to login to graphical desktop?

Postby jb_11000 » 2021-02-08 23:43

mangoduck wrote:Just having a script doesn't do anything; what calls the script? And when?

When I man xrdb, it appears that it sets properties for x clients to use based on the passed file. I don't have a .Xresources file in my home directory, though. What needs to be in it? What format do I use to specify the properties? Where did you get your .Xresources file from? What all needs to be in it?

I do not have a vncconfig command; I think that's TigerVNC specific.

When I try to run the xfce4-session command, or the dbus-launch command that runs the xfce4-session command, I get the following error:
Code: Select all
xfce4-session: Cannot open display: .


I'm familiar how to specify which display x11vnc uses, and have tried :0 and :1 and the -find option, but the problem is there doesn't appear to be ANY displays for it to use. I think the xstartup script, and the .Xresources file are the key, but I'm having trouble finding info. I found this info about the xrdb command with a description of how to construct an .Xresources file: https://www.computerhope.com/unix/uxrdb.htm, but I'm still not sure what I would need to put into my own .Xresources file to make it work. Could you post the contents of yours?


Like I said I'm only a beginner myself, but I believe that the xstartup script is called when vncserver is run. The .Xresources file doesn't exist on mine either, I think it is created automatically to temporarily store relevant config data.
The vncconfig command I believe is a setting for the window manager, i.e. "iconified"
I don't really know enough to say one way or another why the xfce4-session command didn't work - maybe try running it as a script with the xrdb command, see what happens?

If I were in your shoes I would at least try creating the xstartup script as above (in ~/.vnc) - minus the vncconfig line of course. Then try running your vncserver on display :1 - if it doesn't work, try running the script manually then starting your vnc server.
Have a browse around and look at other options for running dbus-launch for example https://dbus.freedesktop.org/doc/dbus-launch.1.html - you may have to specify a different window manager (for example).

If all else fails, get TigerVNC instead, if I can follow their documentation successfully then anyone can! Good luck
jb_11000
 
Posts: 7
Joined: 2021-02-05 16:08

Re: How to use x11vnc to login to graphical desktop?

Postby pcalvert » 2021-02-09 09:01

About four years ago I tested and used several methods of connecting to a remote machine, including x11vnc. I believe that what you are seeking can be accomplished using xrdp and xorgxrdp. To access the "remote" machine, you would use Remmina along with the remmina-plugin-rdp package.

If you're interested in trying this, I may have some notes that may be helpful. Let me know and I'll look for them.

Phil
“It is better to believe than to disbelieve; in doing so, it brings
everything into the realm of possibility.” — Albert Einstein
pcalvert
 
Posts: 1920
Joined: 2006-04-21 11:19
Location: Sol Sector

Re: How to use x11vnc to login to graphical desktop?

Postby trinidad » 2021-02-09 14:38

Well if you think auto-login is not secure, which is only really a problem if someone else has in the room access, since you're connecting in the first place with ssh, and that's your security for the host's connections, and you can firewall off all the other ports, and you can shutdown your host at any time with ssh from your client cli, there are only a few other options. It appears you are running XFCE. Reconfigure lightdm to accept TCP, and host X on your Desktop with a second display or nested xserver (don't need x11vnc), or use xdcmp. Also x11vnc password is a good idea especially if you are running startup scripts, and are apparently concerned about in the room security, and/or apparently don't trust your own ssh security. Consider whether or not you really need full virtual desktop access, and if not just use ssh x11 forwarding for specific applications instead.

I would (since you already apparently running Xorg anyway) use both wake-on-lan and auto-login with what you are trying to do, and use x11vnc with a password, and passworded ssh with a tunnel and an obscure port, and user IP address limits, and Remmina. I could then boot and start my host's x from my client, use my virtual desktop, use sftp, and shut down my host whenever I like, and I personally wouldn't worry about the security of the host at all, since someone would have to be in the room to access it. And in that same vein (considering you somehow think auto-login is a security problem) consider the fact that the more you automate your client's connections to your host via scripts and keys, the less secure you make your host, if someone gets in the room access to your client.

TC
You can't believe your eyes if your imagination is out of focus.
trinidad
 
Posts: 167
Joined: 2016-08-04 14:58


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 10 guests

fashionable