本地文件

本地文件

我想运行一个远程 gnome 终端并让 X11 应用程序在本地显示。

这应该可以解决问题但没有解决(“无法打开显示”):

ssh -Y user@host gnome-terminal

这不是我想要的,因为它只适用于一个标签:

gnome-terminal -e 'ssh -Y user@host'

这是正确的做法,但需要额外的步骤和窗口:

ssh -Y user@host
gnome-terminal &

这可以实现我想要的功能,但是需要使用 xterm:

ssh -Y user@host xterm

最后,我想为第一个创建一个别名,但它不起作用!我错过了什么?!

谢谢 =)

答案1

这种命令的ssh [username@]servername -X其中 username@ 是可选的但很有用,它可以指示 SSH 使用正确的用户名来仅询问密码,之后您最喜欢的应用程序的所有 GUI 都将显示在您的桌面上而不是远程桌面上。

此外,您可能希望使用SSHPass(在终端中安装sudo apt-get install sshpass)来创建自定义SSH 脚本这样你只需一条指令就可以连接到你的服务器,如下所示:

本地文件

#!/bin/bash
sshpass -p "PASSWORD" ssh username@server -p [PORT] -X

假设您的 SSH 服务器有192.168.1.100IP 地址并且用户有webuser密码12345,那么命令将如下所示:

sshpass -p "12345" ssh [email protected] -X
  • 请记住,必须是大写,这一点很重要-X

通过授予适当的执行权限后,sudo chmod +x local.sh您可以通过以下方式在终端中调用它./local.sh

如果你希望进一步了解,可以将其放在/usr/bin目录中,以便可以直接通过终端或启动器调用它,local.sh或者可以将其重命名为单个单词命令,例如sshlocal

现在。一旦连接到服务器,您就不需要打开终端了。所有命令的执行都像您在服务器的本地终端中一样。但:如果您希望执行,则屏幕上将出现gnome-terminal一个远程 GUI 。gnome-terminal

请尝试一下,如果成功请告知。

有用的信息

 -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.


   -Y      Enables trusted X11 forwarding.  Trusted X11 forwardings are not
             subjected to the X11 SECURITY extension controls.

来源:http://manpages.ubuntu.com/manpages/precise/man1/ssh.1.html

祝你好运!

相关内容