0

I recently followed a guide I found here: How to Install VNC Server on RHEL 8 to create a VNC session for a given user. I have since created a new user account: engineer and updated the systemd service file to point to the new user account as shown below:

[engineer@localhost ~]$ cat /etc/systemd/system/[email protected]
[Unit]
Description=Remote Desktop Service (VNC)
After=syslog.target network.target

[Service]
Type=forking
WorkingDirectory=/home/engineer
User=engineer
Group=engineer

PIDFile=/home/engineer/.vnc/%H%i.pid

ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver -autokill %i
ExecStop=/usr/bin/vncserver -kill %i

[Install]
WantedBy=multi-user.target

I created a new vnc password for the engineer account and then executed the systemctl daemon-reload command after creating my service file, then executed the command: systemctl start vncserver@:1 as per the guide and now I get the follow error message:

Failed to import environment: Process org.freedesktop.systemd1 exited with status 1

Annoyingly everything was working fine until updated the vncserver@ service file.

Interestingly if I revert all the settings in the service file back to the original user it works without fail.

hymcode
  • 19
  • 5
  • can you add to the question the output of `systemctl --user status` and `systemctl --state=failed --all' ? – D'Arcy Nader Aug 31 '23 at 15:28
  • Hello @D'ArcyNader I tried to execute the first command you mentioned and the got the error: `Failed to connect to bus: No such file or directory` – hymcode Aug 31 '23 at 15:58

1 Answers1

0

This may not be an answer per se, but I found an simpler implementation of what I need based on information I have found from the following two sources, so I thought I'd share:

  1. How to configure VNC server in Red Hat Enterprise Linux 8
  2. Tigervnc black screen

The steps below are under the assumption that you have installed TigerVNC and done nothing more.

Firstly I signed into the user account and created a vnc password by executing the command:

$ vncpasswd

I did not set a view only password when prompted.

Next I modified the vncserver.user file located in: /etc/tigervnc/ and added my user by following the examples in the file.

After saving my changes I copied the user environment config template from the /etc/tigervnc/ directory to my user account home directory by executing the following command:

$ cp /etc/tigervnc/vncserver-config-mandatory ~/.vnc/config

After copying the template, I edited the config file to define my session and desired screen resolution:

session=xfce4-session
geometry=1920x1080

Next I copied the systemd service template by executing the command:

$ sudo cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service

After copying the file to the correct directory I modified it with the following two lines:

Restart=on-success
RestartSec=15

The reasons I added these two line is I noticed that if you logout of the desktop environment while using the VNC session it will actually stop the systemd service file. These additional lines will check this and then restart the service after 15 seconds.

The final steps taken were to first start the systemd service by executing the command:

$ sudo systemctl start vncserver@:1 

Then I checked the systemd service had started successfully via the command:

$ sudo systemctl status vncserver@:1

Once confirmed the systemd service had started I attempted a connection to the IP Address with the port: 5901.

After I was happy with everything, I enabled the systemd service so that it starts during boot:

$ sudo systemctl enable vncserver@:1

I hope this information will be helpful to others.

hymcode
  • 19
  • 5