![无法通过 SSH 使 gnome-session 工作](https://linux22.com/image/25039/%E6%97%A0%E6%B3%95%E9%80%9A%E8%BF%87%20SSH%20%E4%BD%BF%20gnome-session%20%E5%B7%A5%E4%BD%9C.png)
要通过 ssh 从我的家庭计算机登录我的办公室计算机,我需要执行以下两个步骤:首先登录到我的办公室服务器:ssh -X myOfficeServerID@myofficeServer
然后使用本地 IP 登录到我的计算机:ssh -X myOfficeComputerID@myOfficeComputerIP
。我希望能够远程查看我的桌面并使用 GUI。
这是运行的结果gnome-session
:
[myOfficeComputerID@myOfficeComputer]$gnome-session
gnome-session[17491]: WARNING: Unable to determine session: Unable to lookup session information for process '17491'
GNOME_KEYRING_SOCKET=/tmp/keyring-TokklK/socket
SSH_AUTH_SOCK=/tmp/keyring-TokklK/socket.ssh
GNOME_KEYRING_PID=17507
** (gnome-settings-daemon:17510): WARNING **: You can only run one xsettings manager at a time; exiting
** (gnome-settings-daemon:17510): WARNING **: Unable to start xsettings manager: Could not initialize xsettings manager.
** (gnome-settings-daemon:17510): WARNING **: Connection failed, reconnecting...
** (gnome-settings-daemon:17510): WARNING **: Failed to connect context: Connection refused
Window manager warning: Screen 0 on display "localhost:10.0" already has a window manager; try using the --replace option to replace the current window manager.
Window manager warning: Screen 0 on display "localhost:10.0" already has a window manager; try using the --replace option to replace the current window manager.
Starting Dropbox...Connection failure: Connection refused
pa_context_connect() failed: Connection refused
Done!
(polkit-gnome-authentication-agent-1:17571): polkit-gnome-1-WARNING **: Unable to determine the session we are in: Remote Exception invoking org.freedesktop.ConsoleKit.Manager.GetSessionForUnixProcess() on /org/freedesktop/ConsoleKit/Manager at name org.freedesktop.ConsoleKit: org.freedesktop.ConsoleKit.Manager.GeneralError: Unable to lookup session information for process '17571' org.freedesktop.ConsoleKit.Manager.GeneralError Unable%20to%20lookup%20session%20information%20for%20process%20%2717571%27
system-config-printer-applet: failed to start NewPrinterNotification service
** (gnome-panel:17538): CRITICAL **: panel_applet_frame_change_background: assertion `PANEL_IS_WIDGET (GTK_WIDGET (frame)->parent)' failed
** (nm-applet:17578): WARNING **: <WARN> request_name(): Could not acquire the NetworkManagerUserSettings service.
Error: (9) Connection ":1.261" is not allowed to own the service "org.freedesktop.NetworkManagerUserSettings" due to security policies in the configuration file
Failed to play sound: Not available
** (gnome-volume-control-applet:17590): WARNING **: Connection failed, reconnecting...
** (gnome-volume-control-applet:17590): WARNING **: Failed to connect context: Connection refused
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
** (gnome-volume-control-applet:17590): WARNING **: Connection failed, reconnecting...
** (gnome-volume-control-applet:17590): WARNING **: Failed to connect context: Connection refused
** (gnome-settings-daemon:17510): WARNING **: Grab failed for some keys, another application may already have access the them.
** (gnome-settings-daemon:17510): WARNING **: Clipboard manager is already running.
** (gnome-settings-daemon:17510): WARNING **: Connection failed, reconnecting...
** (gnome-settings-daemon:17510): WARNING **: Failed to connect context: Connection refused
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
failed to create drawable
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
^CTraceback (most recent call last):
File "/usr/share/system-config-printer/applet.py", line 434, in <module>
waitloop.run()
KeyboardInterrupt
** Message: Got disconnected from the session message bus; retrying to reconnect every 10 seconds
(gnome-settings-daemon:17510): GConf-WARNING **: Directory `/desktop/gtk' was not being monitored by GConfClient 0xda21e0
(gnome-settings-daemon:17510): GConf-WARNING **: Directory `/desktop/gnome/interface' was not being monitored by GConfClient 0xda21e0
(gnome-settings-daemon:17510): GConf-WARNING **: Directory `/apps/gnome_settings_daemon/gtk-modules' was not being monitored by GConfClient 0xda21e0
(gnome-settings-daemon:17510): GConf-WARNING **: Directory `/desktop/gnome/font_rendering' was not being monitored by GConfClient 0xda21e0
(gnome-settings-daemon:17510): GConf-WARNING **: Directory `/desktop/gnome/sound' was not being monitored by GConfClient 0xda21e0
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-gk7tyDBsRK: Connection refused)
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-gk7tyDBsRK: Connection refused)
[myOfficeComputerID@myOfficeComputer ~]$
(gnome-settings-daemon:17510): GConf-WARNING **: Directory `/desktop/gnome/peripherals/mouse' was not being monitored by GConfClient 0xda21e0
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-gk7tyDBsRK: Connection refused)
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-gk7tyDBsRK: Connection refused)
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-gk7tyDBsRK: Connection refused)
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-gk7tyDBsRK: Connection refused)
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-gk7tyDBsRK: Connection refused)
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-gk7tyDBsRK: Connection refused)
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-gk7tyDBsRK: Connection refused)
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-gk7tyDBsRK: Connection refused)
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-gk7tyDBsRK: Connection refused)
^C
这些命令将继续不间断地运行,直到我按下 ^C,正如您在命令中看到的那样:
Initializing nautilus-gdu extension
Initializing nautilus-open-terminal extension
Initializing nautilus-dropbox 1.4.0
Shutting down dropbox extension
Shutting down nautilus-open-terminal extension
Shutting down nautilus-gdu extension
与此同时,诸如firefox
从我的办公室计算机运行的东西,但底部面板不会停止加载东西。
答案1
两个 SSH 会话都需要使用 -X 选项启动。
但是,如果您想要整个会话,您可能需要考虑使用类似的东西X2go因为它压缩图像并有一些代理,这使得带宽消耗少很多并且它可以恢复会话......
当您的远程 gnome 会话启动远程元城市来取代本地窗口管理器时,运行整个 gnome 会话可能会产生令人不快的副作用。
您的附加信息显示了我提到的“令人不快的副作用”。当你已经有一个正在运行的桌面环境时,你不能简单地运行gnome-session
,因为 gnome-session 会尝试接管,而你正在运行的桌面环境不会那么容易让它这么做。对于 X 程序来说,无论是通过 SSH 远程运行还是在本地运行,都没有什么区别。
根据您想要实现的目标,您可以启动一个xnest
会话并将其用于远程 gnome 会话。
xnest -geometry 1280x1024 :123 &
DISPLAY=:123 ssh -X firsthop
ssh -X secondhop
gnome-session
注意:在某些发行版中,二进制文件Xnest
以大写 x 命名。
答案2
我遇到了同样的错误,打开了一堆文件浏览器(nautilus)实例,但我无法正确连接到我的帐户。
我今天发现的原因是,我的 ~.cshrc 中有这一行:“setenv DISPLAY unix:0.0”
注释掉之后,一切正常。因此,显然通过 ssh 连接时显示设置了两次,每个 ssh 一次,每个 user-cshrc 一次,导致一些混乱。
答案3
图形会话无法通过 SSH 启动,您需要使用 VNC 服务器或远程桌面连接。 SSH 只会为您提供 shell 访问权限,因为您登录计算机的方式不允许您将 gnome-session 打开到您可以访问的 X-Session 中。因此,如果您的目标是获得完整的图形桌面(可以通过 RealVNC 等 VNC 查看器连接到该桌面),请使用 VNC。您可以通过安装在您的计算机上设置 VNC 服务器tightvncserver
。安装后,您可以通过在 shell 中输入以下内容来启动 VNC 服务器tightvnc
username@hostname $tightvncserver --geometry 1024x760
答案4
也许您刚刚忘记了命令:(xhost +
就在 ssh 命令之前:)ssh -XY username@servername
。