vncserver closed when I close the ssh terminal

Hi.

This issue appeared after upgrading opensuse to 15.1

I’m using vncserver launching LXDE


fperal@tutatis:~> cat .vnc/xstartup
#!/bin/sh
/usr/bin/lxsession &

I enter the server using ssh and then


vncserver  -geometry 1920x1080 :1

VNC server boots ok, and I can work fine… provided I keep the ssh terminal (from which I launched vncserver) running. If I close the terminal, lxde dies … in fact the vncserver session does not die… maybe even lxde, as it keeps the wall paper, but all the icons and the windows dissapear from the desktop.

any idea why this behavior and how to change it?

best regards

By default logind terminates all processes that are part of user session.

and how to change it?

See description of KillUserProcesses= in man logind.conf. If 15.1 already supports it, there are also KillOnlyUsers=, KillExcludeUsers=.

You may consider writing user service so vncserver is started outside of normal interactive session and enable lingering for your user. This would also ensure vncserver remains after session is terminated.

It was not the way it worked before, I used to open a ssh session, run “vncserver -geometry 1920x1080 :1” close the ssh session, and the vnc server was persistent.
This way I have used in several machines, it always worked.

I have been trying with scree and tmux both of them may keep the process running when you close the terminal.
But both of them fail to do so in this case.

In fact I have seen that vnc is not killed.

This are the process running when lxde is working in the vncserver


fperal   11450  3.0  0.9 1523864 151384 pts/0  Sl   12:21   0:04 /usr/bin/Xvnc :1 -auth /home/fperal/.Xauthority -desktop tutatis:1 (fperal) -fp /usr/share/fonts/misc,/usr/share/fonts/75dpi,/usr/share/fonts/100dpi,/usr/share/fonts/Speedo,/usr/share/fonts/Type1 -geometry 1920x1080 -pn -rfbauth /home/fperal/.vnc/passwd -rfbport 5901 -rfbwait 30000
fperal   11475  0.0  0.2 412332 40968 pts/0    Sl   12:21   0:00 /usr/bin/lxsession
fperal   11477  0.0  0.0  42124  4560 ?        Ss   12:21   0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
fperal   11479  0.0  0.0 281496  6688 ?        Ssl  12:21   0:00 /usr/lib/gvfs/gvfsd
fperal   11484  0.0  0.0 416044  5216 ?        Sl   12:21   0:00 /usr/lib/gvfs/gvfsd-fuse /run/user/500/gvfs -f -o big_writes
fperal   11495  0.1  0.2 228548 46020 pts/0    S    12:21   0:00 openbox --config-file /home/fperal/.config/openbox/lxde-rc.xml
fperal   11498  0.0  0.2 355664 40260 pts/0    Sl   12:21   0:00 lxpolkit
fperal   11500  0.6  0.3 839120 61908 pts/0    Sl   12:21   0:00 lxpanel --profile LXDE
fperal   11501  0.1  0.3 704232 55200 pts/0    Sl   12:21   0:00 pcmanfm --desktop --profile LXDE
fperal   11502  0.0  0.0  47264  4676 pts/0    S    12:21   0:00 xscreensaver -no-splash
fperal   11504  0.0  0.2 202688 35188 pts/0    S    12:21   0:00 lxclipboard
fperal   11510  0.2  0.2 296636 39080 pts/0    Sl   12:21   0:00 /usr/bin/python3 /usr/share/system-config-printer/applet.py
fperal   11514  0.0  0.2 433308 42364 pts/0    Sl   12:21   0:00 pk-update-icon
fperal   11520  0.1  0.3 566980 57096 pts/0    Sl   12:21   0:00 nm-applet
fperal   11522  0.1  0.2 341520 42132 pts/0    Sl   12:21   0:00 parcellite
fperal   11524  0.1  0.3 793344 61324 pts/0    Sl   12:21   0:00 /usr/lib/deja-dup/deja-dup-monitor
fperal   11526  0.0  0.0  26300  8760 pts/0    S    12:21   0:00 /usr/bin/python3 /usr/bin/blueberry-tray
fperal   11534  0.0  0.0  15836   460 ?        Ss   12:21   0:00 /usr/bin/ssh-agent -s
fperal   11541  0.3  0.6 952824 106292 ?       Ssl  12:21   0:00 /usr/bin/python3 /usr/bin/hp-systray -x
fperal   11552  0.1  0.3 431580 58616 pts/0    Sl   12:21   0:00 python2 /usr/lib/blueberry/blueberry-tray.py
fperal   11556  0.0  0.0 293316  8752 ?        Sl   12:21   0:00 /usr/bin/pulseaudio --start --log-target=syslog
fperal   11558  0.0  0.2 393316 33332 ?        Ssl  12:21   0:00 xfce4-power-manager
fperal   11563  0.0  0.0 345096  5640 ?        Ssl  12:21   0:00 /usr/lib/at-spi2/at-spi-bus-launcher
fperal   11569  0.0  0.0  41612  4008 ?        S    12:21   0:00 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
fperal   11576  0.0  0.0 192332  5560 ?        Sl   12:21   0:00 /usr/lib/menu-cache/menu-cached /run/user/500/menu-cached-:1
fperal   11583  0.0  0.0 218648  5220 ?        Sl   12:21   0:00 /usr/lib/at-spi2/at-spi2-registryd --use-gnome-session
fperal   11598  0.0  0.0  85540  3836 ?        S    12:21   0:00 /usr/lib/pulse/gconf-helper
fperal   11600  0.0  0.0  64192  5424 ?        S    12:21   0:00 /usr/lib/GConf/2/gconfd-2
fperal   11606  0.0  0.0 311632  9288 ?        Ssl  12:21   0:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
fperal   11613  0.0  0.0 485616  7692 ?        Ssl  12:21   0:00 /usr/lib/xdg-document-portal
fperal   11617  0.0  0.0 261784  4868 ?        Ssl  12:21   0:00 /usr/lib/xdg-permission-store
fperal   11626  0.0  0.0 264280  5596 ?        Ssl  12:21   0:00 /usr/lib/gvfs/gvfs-goa-volume-monitor
fperal   11637  0.0  0.3 776076 60324 ?        Sl   12:21   0:00 /usr/lib/goa-daemon
fperal   11641  0.0  0.1 295156 24056 ?        Sl   12:21   0:00 /usr/bin/python3 /usr/bin/hp-systray -x
fperal   11642  0.0  0.1 190636 19496 ?        S    12:21   0:00 /usr/bin/python3 /usr/bin/hp-systray -x
fperal   11655  0.0  0.0 292912  7256 ?        Sl   12:21   0:00 /usr/lib/goa-identity-service
fperal   11660  0.0  0.0 268280  5052 ?        Ssl  12:21   0:00 /usr/lib/gvfs/gvfs-mtp-volume-monitor
fperal   11664  0.0  0.0 280800  6352 ?        Ssl  12:21   0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
fperal   11668  0.0  0.0 349180  7548 ?        Ssl  12:21   0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
fperal   11679  0.0  0.0 357904  7228 ?        Sl   12:21   0:00 /usr/lib/gvfs/gvfsd-trash --spawner :1.2 /org/gtk/gvfs/exec_spaw/0

And then when i close the terminal only some of them remain.


fperal   11450  0.0  0.6 1451952 104168 ?      Sl   12:21   0:06 /usr/bin/Xvnc :1 -auth /home/fperal/.Xauthority -desktop tutatis:1 (fperal) -fp /usr/share/fonts/misc,/usr/share/fonts/75dpi,/usr/share/fonts/100dpi,/usr/share/fonts/Speedo,/usr/share/fonts/Type1 -geometry 1920x1080 -pn -rfbauth /home/fperal/.vnc/passwd -rfbport 5901 -rfbwait 30000
fperal   11495  0.0  0.2 228548 46020 ?        S    12:21   0:00 openbox --config-file /home/fperal/.config/openbox/lxde-rc.xml
fperal   11502  0.0  0.0  47264  4676 ?        S    12:21   0:00 xscreensaver -no-splash
fperal   11534  0.0  0.0  15836   460 ?        Ss   12:21   0:00 /usr/bin/ssh-agent -s
root     18648  0.0  0.0 128348  8804 ?        Ss   16:32   0:00 sshd: fperal [priv]
fperal   18650  0.0  0.0  74256  7440 ?        Ss   16:32   0:00 /usr/lib/systemd/systemd --user
fperal   18651  0.0  0.0 267192  3284 ?        S    16:32   0:00 (sd-pam)

vnc is one of them… in fact I can connect with vncviewer and the wallpaper is here and the context menu works, but the icons and the taskbar are gone.

… to be continued

Am a bit confused by your description…
Some assumptions…

The 15.1 you’re referring to is likely the remote machine you’re connecting to, not the client.
Aside from your unorthodox way of connecting,
You seem to be describing 3 different layers in your connection…

  • The SSH session
  • The User session
  • The VNC server session running on the remote machine.

Although it would generally be good practice to shutdown each of the 3 layers in the reverse order created,
I think you are asking why it might be that if the SSH session is suddenly terminated which may or may not break the User session logged into the VNC server session running on the remote machine, why the VNC server session continues to run (or not? - I’m confused. Or, is this where your confusion actually is, assuming that the User session is essential to the running VNC server session which is a matter of configuration so is not necessarily so).

Keep in mind that with LEAP 15.0 and continuing through 15.1, VNC server has undergone enormous architectural and configuration changes which are documented everywhere both in the official TigerVNC documentation and in our LEAP documentation. So far, AFAIK legacy setup methods can be forced, but has to be configured manually… A new install is likely very different and if you upgraded instead of installing new may even be different in unexpected ways. Wayland now supports remote sessions, so it now becomes important to know whether you are running Wayland or Xorg X server on your remote machine. “One Time” vs Persistent VNC sessions are now configured differently than before and the defaults may have changed which could possibly explain a different behavior.

TSU

I’m testing on a different computer recently upgraded too to opensuse 15.1 from 42.3.
I’m (and was) using x2go in this computer instead of vncserver. X2go makes persistent virtual graphics sessions, you launch one session, close x2go client and then the session remain so when you connect again the session is there same as last time.

There I have the same issue with lxde sessions through x2go: I open a session, open some windows (for instance firefox, lxterm, etc.), close x2go client, connect again… and the sessions is a new one, the last was not saved.
But if I connect with x2go with a kde session then the session IS persistent.

So it is a lxde issue (in opensuse 15.1, previously it worked fine).

Yes, it is the server.

Aside from your unorthodox way of connecting,
You seem to be describing 3 different layers in your connection…

  • The SSH session
  • The User session
  • The VNC server session running on the remote machine.

Although it would generally be good practice to shutdown each of the 3 layers in the reverse order created,
I think you are asking why it might be that if the SSH session is suddenly terminated which may or may not break the User session logged into the VNC server session running on the remote machine, why the VNC server session continues to run (or not? - I’m confused. Or, is this where your confusion actually is, assuming that the User session is essential to the running VNC server session which is a matter of configuration so is not necessarily so).

I want the session to be persistent. The process
-I open a terminal (konsole in kde, putty in windows…)
-I access the server through ssh
-I launch the vncserver
-I close the terminal

In Opensuse 42.3 the vncserver remain persistent.
Now… in fact vncserver remains, but icons, windows, taskbar… all dissapear in the vnc session. The only thing wich remains is the wallpaper.
-I close the ssh

Keep in mind that with LEAP 15.0 and continuing through 15.1, VNC server has undergone enormous architectural and configuration changes which are documented everywhere both in the official TigerVNC documentation and in our LEAP documentation. So far, AFAIK legacy setup methods can be forced, but has to be configured manually… A new install is likely very different and if you upgraded instead of installing new may even be different in unexpected ways. Wayland now supports remote sessions, so it now becomes important to know whether you are running Wayland or Xorg X server on your remote machine. “One Time” vs Persistent VNC sessions are now configured differently than before and the defaults may have changed which could possibly explain a different behavior.

TSU

I have upgraded it from 42.3 with the offline method.

regards


fperal@tutatis:~> zypper se xorg
Loading repository data...
Reading installed packages...

S  | Name                    | Summary                                                                        | Type      
---+-------------------------+--------------------------------------------------------------------------------+-----------
   | xorg-cf-files           | Data files for the imake utility                                               | package   
   | xorg-docs               | Miscellaneous documentation for the X Window System                            | package   
i+ | xorg-scripts            | Miscellaneous scripts for X                                                    | package   
   | xorg-sgml-doctools      | Set of SGML entities and XML/CSS style sheets for building X.org documentation | package   
i+ | xorg-x11                | Compatibility metapackage for X.Org sample applications                        | package   
i+ | xorg-x11-Xvnc           | TigerVNC implementation of Xvnc                                                | package   
   | xorg-x11-Xvnc-java      | VNC viewer in java                                                             | package   
i+ | xorg-x11-Xvnc-module    | VNC module for X server                                                        | package   
   | xorg-x11-Xvnc-novnc     | NoVNC service for Xvnc                                                         | package   
   | xorg-x11-devel          | Compatibility metapackage for X.Org development libraries                      | package   
i+ | xorg-x11-driver-input   | Compatibility metapackage for X.Org input drivers                              | package   
i+ | xorg-x11-driver-video   | Compatibility metapackage for X.Org video drivers                              | package   
i+ | xorg-x11-essentials     | Compatibility metapackage for X.Org core applications                          | package   
i+ | xorg-x11-fonts          | Tipografías X.Org                                                              | package   
i+ | xorg-x11-fonts-core     | Tipografías de núcleo para X.Org                                               | package   
i+ | xorg-x11-libX11-ccache  | X                                                                              | package   
   | xorg-x11-libs           | Compatibility metapackage for X.Org libraries                                  | package   
i+ | xorg-x11-server         | X                                                                              | package   
   | xorg-x11-server-Xspice  | XSpice is an X server that can be accessed by a Spice client                   | package   
i+ | xorg-x11-server-extra   | Additional Xservers (Xdmx, Xephyr, Xnest)                                      | package   
   | xorg-x11-server-sdk     | X                                                                              | package   
   | xorg-x11-server-source  | Source code of X.Org server                                                    | package   
i+ | xorg-x11-server-wayland | Xwayland Xserver                                                               | package   
   | xorg-x11-util-devel     | Compatibility metapackage for X11 development                                  | package   
   | xorgxrdp                | Xorg drivers for xrdp                                                          | srcpackage
   | xorgxrdp                | Xorg drivers for xrdp                                                          | package   
   | xorgxrdp-debuginfo      | Debug information for package xorgxrdp                                         | package   
   | xorgxrdp-debugsource    | Debug sources for package xorgxrdp                                             | package 


I guess that means it is wayland.

I stay corrected, this is apparently still disabled by default in Leap 15.1.

These cannot be all processes. At least processes related to ssh and systemd are missing. When you show computer output always include command and full output including next shell prompt - only this way can information be correctly interpreted.

Can you show output of “loginctl --no-pager --full user-status fperal” after you have started vncserver as well as upload “journalctl -b” after you have closed ssh session to http://susepaste.org/.

OK, I tested it and as I suspected - LXDE session starts a lot of processes under systemd user instance (and this includes D-Bus). When you exit ssh session, user systemd instance is also stopped which terminates a lot - including D-Bus, which likely brings down most remaining processes.

To preserve them you need to enable lingering for systemd user instance:

loginctl enable-linger fperal

In the previous message I just posted the process which appeared after xvnc and then the precess remaining once I closed the ssh session. As you said closing ssh sessions brings down most of them.

To preserve them you need to enable lingering for systemd user instance:

loginctl enable-linger fperal

yes, it worked.

Two questions I’m not sure about:

I have to include this in a boot scriipt or it is a persistent change?

Is this the same as using KillExcludeUsers=fperal in /etc/systemd/logind.conf?
My logind.conf is this


root@tutatis:/home/fperal> cat /etc/systemd/logind.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See logind.conf(5) for details.

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=no
#InhibitorsMax=8192
#SessionsMax=8192
#UserTasksMax=33%
root@tutatis:/home/fperal> 


Everything by default, so willl not be KillUserProcess=no?

regards

It is persistent.

Is this the same as using KillExcludeUsers=fperal in /etc/systemd/logind.conf?

No.