I want to access an Ubuntu machine remotely via VNC. But I can access the Ubuntu machine only if the user is logged in. I want to access the ubuntu machine via VNC from the login screen itself. We can access all windows machines from the login screen. However we were not able to access the Ubuntu machine from the login screen. There is some way but I am not aware of the details. Can someone give a solution to this problem?
Your best bet is to install xrdp . After installation, you can use an RDP client to connect to the machine - you will then be prompted for your credentials as you would be on the login screen.
Overall, I'd recommend
x11vnc
.TL;DR
Enter your password, it's saved by default in
~/.vnc/passwd
in INSECURE encrypted form. It can be decrypted because the key is known... protect it with filesystem permissions)Save my helper script locally:
From your VNC Client host:
Or, from your VNC Server host, run :
via a terminal (or start it as a daemon with
-forever
as an init.d service, upstart service, systemd unit, or however you wish)Now run your VNC Client of choice from your Client Host, point it at:
127.0.0.1:5900
, login with password saved above.Use the X11 "Magic Cookie"
Most X display managers (like GDM, XDM, KDM) start an initial X11 server and authenticate to it with an MIT Magic Cookie. Depending on your display manager, the magic cookie will be found in one of various locations.
I've had good luck getting a VNC session open on the Ubuntu GDM login screen *NOTE1 by finding the magic cookie with this script:
I can start this script (I called it
start_x11vnc.sh
) anytime via SSH... even before login via thegdm
login screen. It launches anx11vnc
server which I can then connect to over SSH tunnel. (Usessh -L 5900:127.0.0.1:5900
or addLocalForward 5900 127.0.0.1:5900
to your host's entry in~/.ssh/config
).NOTE1: In some new distro releases such as Ubuntu >= 17.10, the GDM login X session display is completely separate from the logged in user's X session display. Therefore, it is necessary to first connect to the GDM X session, login... and finally disconnect and re-connect to the newly started X session. Why they now do it this way is a mystery, but it broke the old version of this script.
To enable GDM login over a VNC ssh remote connection try with X11vnc. See also this answer.
Here's how to do it with VNC, if you don't want to use RDP:
sudo apt-get install x11vnc
(Or through Ubuntu Software Center -> X11VNC Server)Set a password:
Choose
y
to save the password.Create an empty file in
/etc/init
calledx11vnc.conf
:Paste this into the file:
Save and close
That's it! You should now be able to connect with any VNC client even before login.
re: try with X11vnc
x11vnc hasn't been updated since september of 2011!!!! There are known bugs and I'm getting popped by one that triggers a stack smash termination of x11vnc any time a pop-up dialogue (such as clicking the 'file' menu on any window) disconnecting the session.
Raspberry pi's can connect to the desktop manager session on :0, why in the hell is this such a problem for Ubuntu?!?! Why is it necessary to rely on an orphaned, 7 year old program to do this on any modern operating system?