我的系统包括一台运行 Ubuntu 18.04 LTS 的笔记本电脑和一台运行 Centos 7 的服务器。我在 Centos 机器上安装了 tigervnc,并将其全部设置为一个用户使用 Remmina 远程桌面访问该机器。我使用了以下指导。对于我为其设置的第一个用户,它工作正常,但对于我为其设置的第二位用户,桌面显示为黑色。两个用户的配置相同,唯一的变化是配置中的编号和用户凭据。我不知道为什么它对第二个用户不起作用。
我以用户身份登录并运行以下命令创建了 vnc 文件:
vncserver
填写了必填字段,之后在用户主文件夹结构中创建所需的文件。我先为第一个用户执行了此操作,然后为第二个用户执行了此操作。
然后我复制了该文件:
sudo cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:2.service
以下是第二个用户的内容/home/<username>/.vnc/xstartup
,请注意,除用户凭证外,其他内容与第一个用户完全相同:
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
gnome-session –session=gnome-classic &
gnome-panel&
文件内容/etc/systemd/system/vncserver@\:2.service
:
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l <username> -c "/usr/bin/vncserver %i -geometry 1280x1024"
PIDFile=/home/<username>/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
被<username>
用户登录取代。
我使用以下命令启动 vnc 进程,确保我已停止并禁用第一个用户的 vnc 会话:
sudo systemctl daemon-reload
sudo systemctl enable vncserver@:2.service
sudo systemctl start vncserver@:2.service
sudo systemctl status vncserver@:2.service
输出:
● vncserver@:2.service - Remote desktop service (VNC)
Loaded: loaded (/etc/systemd/system/vncserver@:2.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2020-02-06 09:44:37 GMT; 6s ago
Process: 952 ExecStart=/usr/sbin/runuser -l <username> -c /usr/bin/vncserver %i -geometry 1280x1024 (code=exited, status=0/SUCCESS)
Process: 947 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
Main PID: 1011 (Xvnc)
CGroup: /system.slice/system-vncserver.slice/vncserver@:2.service
‣ 1011 /usr/bin/Xvnc :2 -auth /home/<username>/.Xauthority -desktop venus:2 (<username>) -fp catalogue:/etc/...
Feb 06 09:44:33 venus systemd[1]: Starting Remote desktop service (VNC)...
Feb 06 09:44:37 venus systemd[1]: Started Remote desktop serv
日志文件的输出/home/<username>/.vnc/venus\:2.log
:
Xvnc TigerVNC 1.8.0 - built Aug 9 2019 03:04:19
Copyright (C) 1999-2017 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12001000, The X.Org Foundation
Thu Feb 6 09:44:34 2020
vncext: VNC extension running!
vncext: Listening for VNC connections on all interface(s), port 5902
vncext: created VNC server for screen 0
/home/<username>/.vnc/xstartup: line 15: gnome-panel: command not found
GLib-GIO-Message: 09:44:37.641: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications.
** (process:1046): WARNING **: 09:44:37.688: Could not make bus activated clients aware of XDG_CURRENT_DESKTOP=GNOME environment variable: Could not connect: Connection refused
Thu Feb 6 09:44:50 2020
Connections: accepted: 10.0.12.148::59266
SConnection: Client needs protocol version 3.8
SConnection: Client requests security type VeNCrypt(19)
SVeNCrypt: Client requests security type TLSVnc (258)
Thu Feb 6 09:44:53 2020
VNCSConnST: Server default pixel format depth 24 (32bpp) little-endian rgb888
VNCSConnST: Client pixel format depth 15 (16bpp) little-endian rgb555
Thu Feb 6 09:45:19 2020
Connections: closed: 10.0.12.148::59266 (Clean disconnection)
EncodeManager: Framebuffer updates: 1
EncodeManager: Tight:
EncodeManager: Solid: 1 rects, 1.31072 Mpixels
EncodeManager: 15 B (1:174763 ratio)
EncodeManager: Total: 1 rects, 1.31072 Mpixels
EncodeManager: 15 B (1:174763 ratio)
TLS: TLS session wasn't terminated gracefully
ComparingUpdateTracker: 0 pixels in / 0 pixels out
ComparingUpdateTracker: (1:-nan ratio)
该日志文件的这一部分似乎与为第一个用户创建的日志文件不同:
** (process:1046): WARNING **: 09:44:37.688: Could not make bus activated clients aware of XDG_CURRENT_DESKTOP=GNOME environment variable: Could not connect: Connection refused
任何帮助将不胜感激。
答案1
事实证明,解决方案是删除蟒蛇框架来自 $PATH环境变量。因此,在我的例子中,用户/home/<username>/.bashrc
文件需要注释掉以下字段,如下所示:
#__conda_setup="$('/home/<username>/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
#if [ $? -eq 0 ]; then
# eval "$__conda_setup"
#else
# if [ -f "/home/<username>/anaconda3/etc/profile.d/conda.sh" ]; then
# . "/home/<username>/anaconda3/etc/profile.d/conda.sh"
# else
# export PATH="/home/<username>/anaconda3/bin:$PATH"
# fi
#fi
#unset __conda_setup
运行source .bashrc
。然后就可以使用远程桌面了。建立连接后,您便可以在远程桌面上使用,取消注释上述行并运行source .bashrc
即可使用蟒蛇在远程桌面会话中。