DietPi VNC Server Headless....head wrecked! Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
User avatar
Joulinar
Posts: 2052
Joined: Sat Nov 16, 2019 12:49 am

Re: DietPi VNC Server Headless....head wrecked!

Post by Joulinar »

So you have a network mount with specific permission attached to your DietPi system?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
feardamhan
Posts: 21
Joined: Tue Apr 28, 2020 12:51 pm

Re: DietPi VNC Server Headless....head wrecked!

Post by feardamhan »

Yeah, ultimately I would like to have multiple users connect to the Pi and haver their own environment to work with.
User avatar
Joulinar
Posts: 2052
Joined: Sat Nov 16, 2019 12:49 am

Re: DietPi VNC Server Headless....head wrecked!

Post by Joulinar »

well I'm not sure if vnc is the right solution because a vnc server has the permissions of the user who runs it. That means for each user you would need to ran an own instance of vncserver with an own display index. That would looks like this on process level

Code: Select all

root@raspberrypi-emby:~# ps -ef |grep vnc
root       416     1  0 21:59 ?        00:00:00 /usr/bin/vncserver-x11-serviced -fg
root       418     1  0 21:59 ?        00:00:00 /usr/bin/vncserver-virtuald -fg
root       429   416  0 21:59 ?        00:00:00 /usr/bin/vncserver-x11-core -service
root       737     1  0 21:59 ?        00:00:00 /usr/bin/vncserver :1 -geometry 1280x720 -depth 16
dietpi     739     1  0 21:59 ?        00:00:00 /usr/bin/vncserver :2 -geometry 1280x720 -depth 16
root       742   737  0 21:59 ?        00:00:00 /usr/bin/Xvnc-core :1 -auth /root/.Xauthority -pn -geometry 1280x720 -depth 16
dietpi     743   739  0 21:59 ?        00:00:00 /usr/bin/Xvnc-core :2 -auth /home/dietpi/.Xauthority -pn -geometry 1280x720 -depth 16
root       744   743  0 21:59 ?        00:00:00 /usr/bin/Xvnc -rootHelper 1000 4
root       775   737  0 21:59 ?        00:00:00 /bin/sh /etc/vnc/xstartup
dietpi     776   739  0 21:59 ?        00:00:00 /bin/sh /etc/vnc/xstartup
root       800     1  0 21:59 ?        00:00:00 /usr/bin/vncserverui virtual 13
dietpi     809     1  0 21:59 ?        00:00:00 /usr/bin/vncserverui virtual 14
root       846   800  0 21:59 ?        00:00:00 /usr/bin/vncserverui -statusicon 5
dietpi     847   809  0 21:59 ?        00:00:00 /usr/bin/vncserverui -statusicon 5
root      1276  1204  0 22:00 pts/0    00:00:00 grep vnc
root@raspberrypi-emby:~#
you see, user root is running usr/bin/vncserver :1 while user dietpi us running /usr/bin/vncserver :2

and finally you can connect to user dietpi environment by using <yourIP:2> on RealVNC client. see attached
Attachments
picture.PNG
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
feardamhan
Posts: 21
Joined: Tue Apr 28, 2020 12:51 pm

Re: DietPi VNC Server Headless....head wrecked!

Post by feardamhan »

That looks like a workable solution. Can you point me in the direction of configuration guidance for that?
User avatar
Joulinar
Posts: 2052
Joined: Sat Nov 16, 2019 12:49 am

Re: DietPi VNC Server Headless....head wrecked!

Post by Joulinar »

you would need to double vncserver.service as well as dietpi vncserver config

Code: Select all

/etc/systemd/system/vncserver.service
/usr/local/bin/vncserver
like this

Code: Select all

root@raspberrypi-emby:~# ls -la /etc/systemd/system |grep vnc
-rw-r--r--  1 root root  319 Apr 30 21:41 vncserver2.service
-rw-r--r--  1 root root  308 Apr 29 15:10 vncserver.service
root@raspberrypi-emby:~#
root@raspberrypi-emby:~# ls -la /usr/local/bin/
-rwxr-xr-x  1 root root 1838 Apr 29 15:10 vncserver
-rwxr-xr-x  1 root root 1840 Apr 30 21:42 vncserver2
root@raspberrypi-emby:~#
that's the service file vncserver2.service

Code: Select all

[Unit]
Description=Manage VNC Server (DietPi)
Before=xrdp.service xrdp-sesman.service
After=dietpi-boot.service

[Service]
RemainAfterExit=yes
User=dietpi
PAMName=login
Environment=HOME=/home/dietpi
ExecStart=/usr/local/bin/vncserver2 start
ExecStop=/usr/local/bin/vncserver2 stop

[Install]
WantedBy=multi-user.target
within vnc server config file /usr/local/bin/vncserver2 you would need to replace 2 times the following line at the bottom

Code: Select all

DISPLAY=$(sed -n '/^[[:blank:]]*SOFTWARE_VNCSERVER_DISPLAY_INDEX=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt)
change it to

Code: Select all

DISPLAY=2
and enable service for autostart

Code: Select all

systemctl enable vncserver2.service
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
feardamhan
Posts: 21
Joined: Tue Apr 28, 2020 12:51 pm

Re: DietPi VNC Server Headless....head wrecked!

Post by feardamhan »

Magic. I’ll give that a go. Does that mean that to change the first vncserver config you would simply edit the first instance of both files and change to an alternate user?
User avatar
Joulinar
Posts: 2052
Joined: Sat Nov 16, 2019 12:49 am

Re: DietPi VNC Server Headless....head wrecked!

Post by Joulinar »

theoretically yes, if you don't need a root instance. or you are going to deactivate the initial first vnc service and manage all users in their own separate files. this way you will keep the possibility to have a root instance if needed
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
feardamhan
Posts: 21
Joined: Tue Apr 28, 2020 12:51 pm

Re: DietPi VNC Server Headless....head wrecked!

Post by feardamhan »

worked perfectly for me. Thanks for all the help Joulinar! 👍
User avatar
Joulinar
Posts: 2052
Joined: Sat Nov 16, 2019 12:49 am

Re: DietPi VNC Server Headless....head wrecked!

Post by Joulinar »

Your welcome. Good that we found a solution for your challenge.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
Joulinar
Posts: 2052
Joined: Sat Nov 16, 2019 12:49 am

Re: DietPi VNC Server Headless....head wrecked!

Post by Joulinar »

Hi,

just another option to play around would be using TigerVNC + xRDP. This will allow to use Windows RPD Client. Looks like it allows Multi-User scenario out of the box. 8)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply