How to change vncserver session from root to user?

I have changed the entries User=root and Environment=HOME=/root in vncserver.service from root to my username and rebooted.
But that doesn’t work. Connection can’t be established anymore.
What else do I have to change to make that work. Because a root Desktop is not really what you want. To many restrictions, besides that fact that it is root.
Would appreciate your help. Thanks.

what is the VNC server you are running? And which user you used?

TigerVNC via dietpi-software
user during configuration was probably root, as the service file suggests

I never understood all the implications that were necessary to change the configuration from root to a user for tigervnc.

Maybe I was not clear enough. To which user you changed configuration?

Just a normal user with sudo access.

Is there anything which I can add?

all clear. Just I need some time to play around with your request as I didn’t know the answer right away. As well I’m doing this on my spare/free time.

I guess you would need to set a password for the VNC user you like to use. Otherwise the service is not able to start

sudo -u <your user> /usr/local/bin/vncserver start

This should ask to set a password. Once done restart your system and check the service afterwards

journalctl -u vncserver.service
systemctl status vncserver.service

No need to explain, I know you are busy. I just wanted to check whether you have all the info you needed.

That was exactly right. No restart required. Thank you so much.

I have a follow up question.
Since I have more than one user I need to change vnc ports for every one of them.
The corresponding files seem not to be recognized, like /etc/tigervnc/vncserver.users
Also I had no success to address a different port with starting the service with systemctl start vncserver@2.service for port 5902.
This is normally the method to do it according to the man page.
But I get confused, there are so many different manuals and versions and distributions out there and so many different options. I get lost.
Do you know how the port (and other options) is/are configured and can be changed here in Dietpi?

I found out that with the command
a new session is created on display 2, exactly what I want:
New Xtigervnc server ‘Thorin:2 (root)’ on port 5902 for display :2.

The question is now: how can that be obtained by starting a service.
I have created two service file vncserver-user1@.service and vncserver-user2@.service
But if start them with vncserver-user1@1.service or @2 or @3 makes no difference. It will always be at port 5901

Also tigervncserver -list would only show me the vncserver started with ‘tigervncserver’ not the one started by service.


I use RealVNC. How can I here connect with a user?
So far it only connects as root.
Also clipboard transfer does not work. Is there a way to fix that?


Same issue here. Just installed DietPi 8.6.1 on Raspi 3 including RealVNC and it behaves different than another installation done a longer while ago (upgraded to 8.6.1. too). Copy & Paste does not work out of the box for the fresh installation done today (running as user root) and i have no idea how to enable it. Nothing found on google fits and works.

:thinking: interesting, even the taskbar icon is missing it seems. Usually there should be one if I’m not mistaken.

Yes, some service seems not to run which also affects the clipboard function.

The VNC port can btw be adjusted with the VNC display index. Display 0 is port 5900, display 1 port 5901 etc. When using our default service, the display can be changed via /boot/dietpi.txt SOFTWARE_VNCSERVER_DISPLAY_INDEX setting. 0 is used for shared sessions attached to a local desktop session, so use 2 onwards. When using a custom service, use :<display> argument when calling the vncserver.

We need to add another setting for choosing the user indeed :thinking:.

1 Like

@MichaIng the issue is not to connect to the VNC server. Basically there are 2 challenges actually. First one would be to enable RealVNC to be able to run as non-root user. But the bigger issue seems to be some missing functionality nowadays. Like being able to copy/past text between client and host.

Does it work when switching to shared session (in /boot/dietpi.txt) instead and (auto)starting a local desktop session where VNC connects to?

Yes, that’s a game changer. Using the shared desktop mode is bringing back the functionality.

That’s how it looks like using local desktop (not shared)

And this is the shared desktop.


As you can see, the taskbar icon is back and you can copy/paste between host and client system.


Hmm, need to have a look into the service, probably something changed the way the RealVNC virtual desktop needs to be started.

Where can I find this config? etc/dietpi.txt does not exist.

It never did. It’s located at /boot/dietpi.txt

I corrected the typo above

1 Like