0xD*_*15B 5 ssh rhythmbox nohup
我是 SSH 新手。我可以连接到远程计算机。我还可以在远程计算机上启动应用程序并在我的屏幕上查看其 GUI。
但是我不知道如何启动应用程序而不在我的屏幕上产生输出。
我想启动一个应用程序(例如 rhythmbox),并关闭 ssh 连接,让应用程序继续运行,而不向我的屏幕发送任何输出。
网上冲浪我找到了一些建议,但没有任何帮助;
ssh -X name@domain
nohup rhythmbox &
logout
Run Code Online (Sandbox Code Playgroud)
您的意思是您希望 Rhythmbox 显示在远程计算机的屏幕上吗?GUI应用程序显示的屏幕由DISPLAY环境变量指示。当您运行时ssh -X,DISPLAY被设置为一个值,该值指示必须通过 SSH 连接转发显示请求。要使应用程序显示在远程计算机的屏幕上,请设置DISPLAY值:0。
ssh username@example.com 'DISPLAY=:0 rhythmbox &'
Run Code Online (Sandbox Code Playgroud)
还有一个障碍:当应用程序连接到 X 显示器时,它需要提供一种称为 cookie 的密码。每次 X 服务器启动时都会生成 cookie。Ubuntu 将 cookie 存储在一个具有随机生成名称的文件中。查找 cookie 的最简单方法是在 X 服务器启动时将其存储在众所周知的文件名中。在 Ubuntu 上,将此代码添加到您的~/.profile:
case $DISPLAY:$XAUTHORITY in
:*:?*)
# DISPLAY is set and points to a local display, and XAUTHORITY is
# set, so merge the contents of `$XAUTHORITY` into ~/.Xauthority.
XAUTHORITY=~/.Xauthority xauth merge "$XAUTHORITY";;
esac
Run Code Online (Sandbox Code Playgroud)
有关更多背景信息,请参阅ssh DISPLAY 变量。
或者您的意思是您永远不想看到 Rhythmbox 窗口?如果是这样,请使其连接到虚拟 X 服务器xvfb
。启动虚拟 X 服务器,然后告诉 Rhythmbox 连接到它。
ssh username@example.com 'Xvfb :1 -screen 0 800x600x8 & sleep 1; DISPLAY=:1 rhythmbox &'
Run Code Online (Sandbox Code Playgroud)