本地.sh

本地.sh

我想運行遠端 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

The command for such thing is ssh [username@]servername -Xwhere username@ is optional but useful in order to instruct SSH to use the right username in order to ask for the password only, after which all the GUI of your favorite applications will show up in your desktop instead of the遠端桌面.

此外,您可能想要使用SSHPass(在終端機中安裝它sudo apt-get install sshpass)來建立自訂SSH 腳本這將允許您使用如下所示的單一指令連接到您的伺服器:

本地.sh

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

假設您的 SSH 伺服器有192.168.1.100IP 位址並且使用者webuser12345密碼命名,那麼命令將如下所示:

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

祝你好運!

相關內容