如何通过 SSH 连接在 Linux 的客户端以图形方式打开和显示文件?

如何通过 SSH 连接在 Linux 的客户端以图形方式打开和显示文件?

我正在使用xdg-open file-name命令在用户端打开并显示文件,但无法通过 SSH 连接在 Linux 中以图形方式在客户端打开并显示文件。所以如果可能的话,请帮我解决这个问题。

答案1

您需要使用该-X选项远程控制

 -X      Enables X11 forwarding.  This can also be specified on a per-host
         basis in a configuration file.

         X11 forwarding should be enabled with caution.  Users with the
         ability to bypass file permissions on the remote host (for the
         user's X authorization database) can access the local X11 display
         through the forwarded connection.  An attacker may then be able
         to perform activities such as keystroke monitoring.

         For this reason, X11 forwarding is subjected to X11 SECURITY
         extension restrictions by default.  Please refer to the ssh -Y
         option and the ForwardX11Trusted directive in ssh_config(5) for
         more information.

服务器端也必须支持X转发/etc/ssh/sshd_config

 X11Forwarding
         Specifies whether X11 forwarding is permitted.  The argument must
         be “yes” or “no”.  The default is “no”.

         When X11 forwarding is enabled, there may be additional exposure
         to the server and to client displays if the sshd(8) proxy display
         is configured to listen on the wildcard address (see
         X11UseLocalhost below), though this is not the default.
         Additionally, the authentication spoofing and authentication data
         verification and substitution occur on the client side.  The
         security risk of using X11 forwarding is that the client's X11
         display server may be exposed to attack when the SSH client
         requests forwarding (see the warnings for ForwardX11 in
         ssh_config(5)).  A system administrator may have a stance in
         which they want to protect clients that may expose themselves to
         attack by unwittingly requesting X11 forwarding, which can
         warrant a “no” setting.

         Note that disabling X11 forwarding does not prevent users from
         forwarding X11 traffic, as users can always install their own
         forwarders.  X11 forwarding is automatically disabled if UseLogin
         is enabled.

然后你就可以使用它了:

$ ssh -X user@host xclock

答案2

只需将“-X”(X11 转发)添加到您的 ssh 命令行即可。这将启用 X11 转发并设置 DISPLAY 变量等,然后您就应该能够执行所要求的操作。

相关内容