I updated the shared server in the laboratory to Ubuntu 18, but noticed that screen sharing by VNC cannot be used. After investigating, it seems that the cause is that x11vnc can no longer be used because the display manager has returned from LightDM to GDM.
The screen sharing of Ubuntu 18 uses Vino and cannot be accessed without logging in. In other words, you have to keep logged in all the time, and when you restart, you have no choice but to go to the site.
There are various solutions.
--Erase GDM and use LightDM → It's a shared server, so it's difficult to change ... --Use only x11vnc → It goes black when you log in --Use another VNC server → I tried using TigerVNC, but it didn't work. ――Do not use screen sharing in the first place → It is a little difficult to do your best just by forwarding X ――Coexistence of x11vnc and vino → It seems that you can do it anywhere ...
In the end, I ended up with this. When you are on the login screen, connect to x11vnc with TCP5901, and after logging in, reconnect to vino with TCP5900.
Simply install vino and enable it in the GUI.
If the client is mac or Windows, you need to decrypt it, so put dconf-editor in it.
After opening dconf-editor, set require-encryption
in org-> gnome-> desktop-> remote-access
to false.
sudo apt install vino dconf-editor
If you set it with the dconf command, you can set it even if you cannot access the GUI. First, check the UUID of the network connection ...
$ nmcli connection show
NAME UUID TYPE DEVICE
docker0 xxxxxxxxxxxxxxxxxxxxxxxxxx bridge docker0
Wired connection 1 yyyyyyyyyyyyyyyyyyyyyyyyyy ethernet enp0s31f6
Specify the connection for which you want to enable vino with dconf write. Since we want to specify Ethernet this time, specify the latter UUID.
dconf write /org/gnome/settings-daemon/plugins/sharing/vino-server/enabled-connections "['yyyyyyyyyyyyyyyyyyyyyyyyyy']"
You can check the settings with dconf read.
$ dconf read /org/gnome/settings-daemon/plugins/sharing/vino-server/enabled-connections
['yyyyyyyyyyyyyyyyyyyyyyyyyy']
Next, install x11vnc.
apt-get install x11vnc
Set the password for x11vnc.
If you do not specify a path, the password file is saved in /home/<user>/.vnc/passwd
.
x11vnc -storepasswd
Create x11vnc.service
to handle VNC as a service.
Since the 5900 port is used by vino, 5901 is used.
Edit /etc/systemd/system/x11vnc.service
as follows.
x11vnc.service
[Unit]
Description=x11vnc (Remote access)
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth /run/user/<UID>/gdm/Xauthority -display :0 -rfbauth /home/<user>/.vnc/passwd -rfbport 5901 -forever -loop -noxdamage -repeat -shared
[Install]
WantedBy=multi-user.target
You can check <UID>
with ps -auxw | grep Xauth
. It is OK if you know the full path of Xauthority
as shown below. In this example, it is 1001.
Maybe you'll see more than one / run/user/<UID>/gdm/Xauthority
, so if you can't connect, try another and it may work. (I thought it was fixed as root, but it doesn't seem to be the case)
$ ps -auxw | grep Xauth
root 19522 0.3 0.2 381404 71100 tty2 Sl+ 14:17 1:41 /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1001/gdm/Xauthority -background none -noreset -keeptty -verbose 3
Finally, run the following to see if the service is running.
$ sudo systemctl daemon-reload
$ sudo systemctl enable x11vnc
$ sudo systemctl start x11vnc
$ sudo systemctl status x11vnc
● x11vnc.service - x11vnc (Remote access)
Loaded: loaded (/etc/systemd/system/x11vnc.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-05-11 18:27:11 JST; 2 weeks 3 days ago
Main PID: 2144 (x11vnc)
Tasks: 2 (limit: 4915)
CGroup: /system.slice/x11vnc.service
├─2144 /usr/bin/x11vnc -auth /run/user/1001/gdm/Xauthority -display :0 -rfbauth /home/ryorsk/.vnc/passwd -rfbport 5901 -forever -loop -noxdamage -repeat -shared
└─2184 /usr/bin/x11vnc -auth /run/user/1001/gdm/Xauthority -display :0 -rfbauth /home/ryorsk/.vnc/passwd -rfbport 5901 -forever -loop -noxdamage -repeat -shared
After that, connect to vnc: // <addr>: 5901
, log in, and reconnect to vnc: // <addr>: 5900
. It's a little annoying, but I'll put up with this because it's only necessary after a reboot. By the way, the above work is completed only in the CUI environment, so it is okay if you forget to set it and throw it in the server room.
http://fx-kirin.com/ubuntu/ubuntu-vnc-server/ https://freefielder.jp/blog/2015/10/ubuntu-vnc-server-on-startup.html https://qiita.com/lin_noob/items/afadb3a8a0897e4be909#7vncx11vnc Server installation
Recommended Posts