vncserver@.service:
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=**user**
PAMName=login
PIDFile=/home/**user**/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
Error:
root@**server**:~# sudo systemctl start vncserver@1
Job for vncserver@1.service failed because the control process exited with error code.
See "systemctl status vncserver@1.service" and "journalctl -xe" for details.
root@**server**:~# sudo systemctl status vncserver@1
● vncserver@1.service - Start TightVNC server at startup
Loaded: loaded (/etc/systemd/system/vncserver@.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2018-04-19 18:34:49 UTC; 18s ago
Process: 3369 ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :1 (code=exited, status=1/FAIL
Process: 3364 ExecStartPre=/usr/bin/vncserver -kill :1 > /dev/null 2>&1 (code=exited, status=2)
Apr 19 18:34:49 **server** systemd[1]: Starting Start TightVNC server at startup...
Apr 19 18:34:49 **server** systemd[3364]: pam_unix(login:session): session opened for user **user** by (uid=0)
Apr 19 18:34:49 **server** systemd[3369]: pam_unix(login:session): session opened for user **user** by (uid=0)
Apr 19 18:34:49 **server** systemd[1]: vncserver@1.service: Control process exited, code=exited status=1
Apr 19 18:34:49 **server** systemd[1]: Failed to start Start TightVNC server at startup.
Apr 19 18:34:49 **server** systemd[1]: vncserver@1.service: Unit entered failed state.
Any idea what I’m doing wrong?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
The error you shared leads me to believe this may be an issue related to the permissions given to the user account you are running the service under. Are you able to start vncserver normally from the command line?
If you update your systemd service to use the user “root” does the service start properly? (not that I’d recommend keeping this configuration, but testing this can confirm if it’s a permissions issue with the user account specified).
Personally I switched from using VNC on my servers to using x2go when needing a remote desktop. It tends to be easier to set up, better performing and more secure since it tunnels over ssh. This script can be used to install and start x2go with xfce on Ubuntu 14.04 and newer.
I just installed Fedora 30 and the template file had:
/usr/bin/vncserver -kill %i
not
/usr/bin/vncserver -kill :%i
But your example has :%i
Just wanted to note it here for anybody else who has the same problem.
I inputted this command ausearch -c ’(ncserver)’ –raw and the output was -raw is an unsupported option.