How to enable X11 forwarding in PyCharm SSH session?

前端 未结 3 2078
感情败类
感情败类 2020-12-23 12:24

The Question

I\'m trying to enable X11 forwarding through the PyCharm SSH Terminal which can be executed via

         


        
相关标签:
3条回答
  • 2020-12-23 12:33

    Update 2020: I found a very easy solution. It may be due to the updated PyCharm version (2020.1).

    1. Ensure that X11Forwarding is enabled on server: In /etc/ssh/sshd_config set
    X11Forwarding yes
    X11DisplayOffset 10
    X11UseLocalhost no
    
    1. On client (MacOS for me): In ~/.ssh/config set
    ForwardX11 yes
    
    1. In PyCharm deselect Include system environment variables. This resolves the issue that the DISPLAY variable gets set to the system variable.

    EDIT: As seen in the below image it works. For example I used the PyTorch implementation of DeepLab and visualize sample images from PASCAL VOC:

    0 讨论(0)
  • 2020-12-23 12:37

    In parallel, open MobaXTerm and connect while X11 forwarding checkbox is enabled. Now PyCharm will forward the display through MobaXTerm X11 server. This until PyCharm add this 'simple' feature.

    Also, set DISPLAY environment variable in PyCharm run configuration like this: DISPLAY=localhost:10.0 (the right hand side should be obtained with the command echo $DISPLAY in the server side)

    0 讨论(0)
  • 2020-12-23 12:46

    So I was able to patch up jsch and test this out and it worked great.

    Using X11 forwarding

    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.

    Compilation

    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
    

    This will create jsch-0.1.54.jar in target folder.

    0 讨论(0)
提交回复
热议问题