如何使用遠端伺服器上執行的編輯器開啟本機文件

如何使用遠端伺服器上執行的編輯器開啟本機文件

我可以在遠端伺服器上運行程序,例如

ssh -Y [email protected] gvim

然而 gvim 只能看到遠端伺服器上的檔案。是否可以從遠端伺服器運行程序,但可以在本地文件上運行?

答案1

你的本機必須運行 ssh,然後你可以這樣做

localusername@localmachine: ssh username@server -R 10000:localmachine:22
username@server: cd /var
username@server: sshfs -p 10000 -o idmap=user,nonempty \
                 [email protected]:~/mywwwdevelstuff www

取自https://superuser.com/a/918708/25609

答案2

我首先將scp本地文件傳輸到遠端伺服器。

當然,在本機系統上安裝 gvim 可能會更好。

答案3

您可以像這樣在遠端電腦上執行程式: ssh -t <user>@<remote host> '<program to execute with full path and arguments>'

     -t      Force pseudo-terminal allocation.  This can be used to execute arbitrary
             screen-based programs on a remote machine, which can be very useful, e.g.
             when implementing menu services.  Multiple -t options force tty allocation,
             even if ssh has no local tty.

相關內容