Bosse_B
Posts: 1035
Joined: Thu Jan 30, 2014 9:53 am

How to configure VNC server to run without local login?

Sat Apr 18, 2020 6:55 am

I just wonder how to make the vnc server start and run properly if there is no local user logged in on the unit (a headless machine)?
On Raspbian it seems to work fine, but I have now tried to make the same work on a Ubuntu 18.04 installation and there it won't work unless I log in locally first.

I know VNC is part of the Raspbian managed items so raspi-config seems to fix it for you, but can someone please outline how it is done so I can replicate it also to my Ubuntu machine?
Raspi-config just has a single enabling item....

I only have one monitor and it is connected to my Windows 10 PC.
Then I also have a bunch of RPi units ranging from 2-3-4 and on these I can easily work from my PC using the VNC windows. It would be nice to be able to centralize handling of all of these.
Bo Berglund
Sweden

pcmanbob
Posts: 9724
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: How to configure VNC server to run without local login?

Sat Apr 18, 2020 11:48 am

I think the difference between raspbian and ubuntu is that by default when the raspbian desktop is started the user pi is automatically logged in .
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Bosse_B
Posts: 1035
Joined: Thu Jan 30, 2014 9:53 am

Re: How to configure VNC server to run without local login?

Sat Apr 18, 2020 1:31 pm

I think the difference between raspbian and ubuntu is that by default when the raspbian desktop is started the user pi is automatically logged in
Not really, when my RPi units start up they sit on the login screen forever since there is no keyboard or monitor attached (headless).

But on the RPi units the vnc server is started at this point.
So I can use the RealVNC application to connect to the RPi and then I get a login prompt via VNC and then the desktop is shown in the VNC window. This login uses the Raspbian user (pi) for authentication.

NOTE! The login on the Ubuntu VNC uses a password unique to the vnc server and it has to be 6-8 characters long. Longer or shorter not allowed. It does not validate against the Ubuntu user at all.

The way I want it to work also on the Ubuntu 18 computer is how it works on the RPi boxes, but on Ubuntu so far VNC only works if I first log on!

I have found a clumsy workaround for this as follows:
- Start the Ubuntu device
- It will now sit on the login screen (forever)
- Now from my Windows PC open a PuTTY SSH session and log in to the command interface
- At the terminal prompt enter

Code: Select all

vncserver -geometry 1600x900 :1
- Now the vnc server is running in the way needed for a connection from the outside.

But drawbacks:
1) I have to use PuTTY to log in to the Ubuntu machine
2) I have to run a command via PuTTY to start up the vnc server
3) When I log on to the VNC screen it pops up an error message concerning the network where I have to enter my real user password (note: NOT the VNC password) to get it rolling finally.

So my question is still how I can replicate the functionality on Raspbian to the Ubuntu machine?

So what I am after, but have not found out yet how to, is to have it work like on the RPi in Raspbian, i.e.
Bo Berglund
Sweden

pcmanbob
Posts: 9724
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: How to configure VNC server to run without local login?

Sat Apr 18, 2020 1:51 pm

Then I don't know I thought it was related to the user being logged in.

If you work round gives you access, have you thought of calling the command you enter when you log in via ssh, using cron,

you would probably need to add a short time delay so that your pc has booted to the same point as it would be when you ssh in.

So you cron line would look like this

Code: Select all

@reboot sleep 60 && vncserver -geometry 1600x900 :1
you may have to adjust the sleep time by experimentation to find the shortest sleep time, 60 may not be long enough so if it does not work try doubling it to 120 and try again.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

bls
Posts: 713
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: How to configure VNC server to run without local login?

Sat Apr 18, 2020 2:48 pm

Bosse_B wrote:
Sat Apr 18, 2020 6:55 am

I only have one monitor and it is connected to my Windows 10 PC.
Then I also have a bunch of RPi units ranging from 2-3-4 and on these I can easily work from my PC using the VNC windows. It would be nice to be able to centralize handling of all of these.
I run all of my RPis headless from first boot onward. If you're OK with using a VNC server other than RealVNC, you might want to check out https://github.com/gitbls/RPiVNCHowTo. It describes how to set up either TightVNC or TigerVNC on Raspbian, but it also works on other Linux distros.
Pi tools:
Easily and quickly build customized-just-for-you SD Cards: https://github.com/gitbls/sdm
Free your network from your router's DHCP/DNS:https://github.com/gitbls/ndm
Easy strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

raspipat
Posts: 15
Joined: Sun Jul 28, 2019 12:17 pm

Re: How to configure VNC server to run without local login?

Sat Apr 18, 2020 3:21 pm

Bosse_B wrote:
Sat Apr 18, 2020 6:55 am
I just wonder how to make the vnc server start and run properly if there is no local user logged in on the unit (a headless machine)?
Maybe what I wrote in post #10 of this thread will help you

Bosse_B
Posts: 1035
Joined: Thu Jan 30, 2014 9:53 am

Re: How to configure VNC server to run without local login?

Sat Apr 18, 2020 3:59 pm

bls wrote:
Sat Apr 18, 2020 2:48 pm
Bosse_B wrote:
Sat Apr 18, 2020 6:55 am

I only have one monitor and it is connected to my Windows 10 PC.
Then I also have a bunch of RPi units ranging from 2-3-4 and on these I can easily work from my PC using the VNC windows. It would be nice to be able to centralize handling of all of these.
I run all of my RPis headless from first boot onward. If you're OK with using a VNC server other than RealVNC, you might want to check out https://github.com/gitbls/RPiVNCHowTo. It describes how to set up either TightVNC or TigerVNC on Raspbian, but it also works on other Linux distros.
Ok, I did not spell out exactly which vnc server I use on Ubuntu, but it happens to be vnc4server, which is what a lot of the online howto's reference. Some also use TigerVnc etc. Also my Ubuntu runs the Mate flavour of desktop.
So I have not used RealVNC as the server but I am using its client program since I already have it to connect to my many RPi units.
I will have a look at that howto as well, but after I have replied to the next post.
Bo Berglund
Sweden

Bosse_B
Posts: 1035
Joined: Thu Jan 30, 2014 9:53 am

Re: How to configure VNC server to run without local login?

Sat Apr 18, 2020 4:09 pm

raspipat wrote:
Sat Apr 18, 2020 3:21 pm
Bosse_B wrote:
Sat Apr 18, 2020 6:55 am
I just wonder how to make the vnc server start and run properly if there is no local user logged in on the unit (a headless machine)?
Maybe what I wrote in post #10 of this thread will help you
Thanks for the link to the other discussion. It seems a lot like what I have done meanwhile using information from the howto for VNC on Ubuntu 18.04 at linuxconfig.com I found just an hour back.
It details how to set up the vncserver as a systemd service, so it starts at boot.
I have done this and after a reboot I could in fact connect to the Ubuntu machine by VNC even though the Ubuntu login is waiting for a logon.
I have to use it a bit more to check that all is working before I declare a full success.

In fact I still have the issue that when connecting via a RealVNC client a login prompt appears and it needs the 6-8 char password that I defined when I did the first test installation and it is NOT using the user login as does the vnc server on Raspbian...
This password is still used even though I have made several apt remove and install for different flavors of vnc servers (TigerVNC and vnc4all to name two).
Bo Berglund
Sweden

Return to “General discussion”