如何在PyCharm SSH会话中启用X11转发? [英] How to enable X11 forwarding in PyCharm SSH session?
问题描述
我正在尝试通过 PyCharm SSH终端启用 X11转发,该终端可通过
I'm trying to enable X11 forwarding through the PyCharm SSH Terminal which can be executed via
"Tools -> Start SSH session..."
不幸的是,似乎没有办法像在shell中那样指定标志来启用X11转发:
Unfortunately, It seems there is no way of specifying the flags like I would do in my shell for enabling the X11 Forwarding:
ssh -X user@remotehost
您知道实现此目标的一些聪明方法吗?
我发现的唯一恶意技巧是使用X11转发打开外部ssh连接,然后手动更新环境变量 DISPLAY .
The only dirty hack I found is to open an external ssh connection with X11 forwarding and than manually update the environment variable DISPLAY.
例如,我可以在外部ssh会话上运行:
For example I can run on my external ssh session:
vincenzo@remotehost:$ echo $DISPLAY
localhost:10.0
而不是在我的PyCharm终端上设置:
And than set on my PyCharm terminal:
export DISPLAY=localhost:10.0
如果要从GUI运行程序,请
或在运行/调试配置中更新 DISPLAY 变量.
or update the DISPLAY variable in the Run/Debug Configuration, if I want to run the program from the GUI.
但是,我真的不喜欢使用外部ssh终端并手动更新 DISPLAY 变量的解决方案,我敢肯定有一种更好的方法来实现这!
However, I really don't like this solution of using an external ssh terminal and manually update the DISPLAY variable and I'm sure there's a better way of achieving this!
任何帮助将不胜感激.
P.s.制作一个别名,如:
P.s. Making an alias like:
alias ssh='ssh -X'
我的 .bashrc 中的
并不强制PyCharm启用X11转发.
in my .bashrc doesn't force PyCharm to enable X11 forwarding.
推荐答案
因此,我能够修补jsch并对其进行测试,并且效果很好.
So I was able to patch up jsch and test this out and it worked great.
您需要执行以下操作才能在PyCharm中使用X11转发:
-如果您还没有X服务器,请安装它.在Windows上,这可能是VcXsrv项目,在Mac OS X上,这可能是XQuartz项目.
-下载或编译jsch软件包.请参阅下面的编译说明.
-在pycharm的lib
文件夹中备份jsch-0.1.54.jar
,并用修补的版本替换.在远程环境中启动Pycharm,并确保删除您可能在运行/调试配置中设置的DISPLAY
环境变量的所有实例.
You will need to do the following to use X11 forwarding in PyCharm:
- Install an X Server if you don't already have one. On Windows this might be the VcXsrv project, on Mac OS X the XQuartz project.
- Download or compile the jsch package. See instructions for compilation below.
- Backup jsch-0.1.54.jar
in your pycharm's lib
folder and replace it with the patched version. Start Pycharm with a remote environment and make sure to remove any instances of the DISPLAY
environment variable you might have set in the run/debug configuration.
这是在装有Maven的Mac OS或Linux系统上需要执行的操作.
Here is what you need to do on a Mac OS or Linux system with Maven installed.
wget http://sourceforge.net/projects/jsch/files/jsch/0.1.54/jsch-0.1.54.zip/download
unzip download
cd jsch-0.1.54
sed -e 's|x11_forwarding=false|x11_forwarding=true|g' -e 's|xforwading=false|xforwading=true|g' -i src/main/java/com/jcraft/jsch/*.java
sed -e 's|<version>0.1.53</version>|<version>0.1.54</version>|g' -i pom.xml
mvn clean package
这将在target
文件夹中创建jsch-0.1.54.jar
.
This will create jsch-0.1.54.jar
in target
folder.
这篇关于如何在PyCharm SSH会话中启用X11转发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!