lk/system/vncserver

78 lines
1.2 KiB
Plaintext
Raw Normal View History

2020-01-02 00:04:35 +00:00
# Ubuntu
https://linuxconfig.org/vnc-server-on-ubuntu-18-04-bionic-beaver-linux
# On server
Enable remote desktop access.
```bash
sudo apt install vnc4server xfce4 xfce4-goodies
```
2020-01-02 00:04:35 +00:00
Disable the vncserver desktop:
```bash
vncserver -kill :1
```
2020-01-02 00:04:35 +00:00
Replace the config in ~/.vnc/xstartup with:
`#!/bin/bash`
`startxfce4 &`
# Arch
Install tigervnc, then run it to set a password:
```bash
vncserver
```
2020-01-02 00:04:35 +00:00
You'll get a session number.
Shut it down with the 'kill' command and the session's number:
```bash
vncserver -kill :1
```
2020-01-02 00:04:35 +00:00
This will forward over port 5900+x where x is the session number. For the first server, that's port 5901.
# Create a systemd service
```bash
sudo vim /etc/systemd/system/vncserver@:1.service
```
2020-01-02 00:04:35 +00:00
Then enter:
> [Unit]
> Description=Remote desktop service (VNC)
> After=syslog.target network.target
>
> [Service]
> Type=simple
> User=foo
> PAMName=login
> PIDFile=/home/%u/.vnc/%H%i.pid
> ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
> ExecStart=/usr/bin/vncserver %i -geometry 1440x900 -alwaysshared -fg
> ExecStop=/usr/bin/vncserver -kill %i
>
> [Install]
> WantedBy=multi-user.target
2020-01-02 00:04:35 +00:00
Then enable that service:
```bash
sudo systemctl start vncserver@:1.service
```
2020-01-02 00:04:35 +00:00