美文网首页
MacOS与远程Linux的图形程序display问题-XQua

MacOS与远程Linux的图形程序display问题-XQua

作者: SnorkelingFan凡潜 | 来源:发表于2020-06-16 23:29 被阅读0次

    问题缘起-报错

    $ ./megacc
    
    (megacc:12728): Gtk-WARNING **: cannot open display:
    

    1. google后发现是因为需要在MacOS本地装XQuartz才能在远程显示(display)图形界面程序
    2. 有一些误导的帖子说需要在Linux下的.bashrc添加环境变量export DISPLAY=IPv4:0.0
    • MacOS本地IPv4地址


      image.png
    1. 尝试后总是Can't open display: 172.16.165.95:0

    正确的解决方案

    1. 安装最新版的XQuartz
      地址:https://www.xquartz.org
    2. 重启电脑 非常重要
    3. 在任何一个终端界面输入xterm,如果弹出新窗口就证明成功安装并且调用
    4. 直接登录Linux ssh -Y username@host
      注意是-Y
    5. 输入xterm测试,可以单出新窗口就证明成功了
      切记,并不需要export DISPLAY=,多此一举就会导致调用不了

    参考:
    1.https://princetonuniversity.github.io/PUbootcamp/ssh-instructions/

    1. https://stackoverflow.com/questions/34919821/gtk-warning-cannot-open-display
    2. https://www.cnblogs.com/andrewwang/p/8535081.html

    按提示在MacOS本地安装XQuartz

    image.png

    新分割线 2020-10-13


    **参考 **
    Instead of using -Y you should use -X
    You will need to add the following to .ssh/config on the Mac side:

    Host *
        XAuthLocation /opt/X11/bin/xauth
    
    

    this is because xauth lives in a different location on macos than it normally would on linux

    我MacOS的原生配置vi /etc/ssh/ssh_config

    #       $OpenBSD: ssh_config,v 1.34 2019/02/04 02:39:42 dtucker Exp $
    
    # This is the ssh client system-wide configuration file.  See
    # ssh_config(5) for more information.  This file provides defaults for
    # users, and the values can be changed in per-user configuration files
    # or on the command line.
    
    # Configuration data is parsed as follows:
    #  1. command line options
    #  2. user-specific file
    #  3. system-wide file
    # Any configuration value is only changed the first time it is set.
    # Thus, host-specific definitions should be at the beginning of the
    # configuration file, and defaults at the end.
    
    # Site-wide defaults for some commonly used options.  For a comprehensive
    # list of available options, their meanings and defaults, please see the
    # ssh_config(5) man page.
    
    # Host *
    #   ForwardAgent no
    #   ForwardX11 no
    #   PasswordAuthentication yes
    #   HostbasedAuthentication no
    #   GSSAPIAuthentication no
    #   GSSAPIDelegateCredentials no
    #   BatchMode no
    #   CheckHostIP yes
    #   AddressFamily any
    #   ConnectTimeout 0
    #   StrictHostKeyChecking ask
    #   IdentityFile ~/.ssh/id_rsa
    #   IdentityFile ~/.ssh/id_dsa
    #   IdentityFile ~/.ssh/id_ecdsa
    #   IdentityFile ~/.ssh/id_ed25519
    #   Port 22
    #   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
    #   MACs hmac-md5,hmac-sha1,umac-64@openssh.com
    #   EscapeChar ~
    #   Tunnel no
    #   TunnelDevice any:any
    #   PermitLocalCommand no
    #   VisualHostKey no
    #   ProxyCommand ssh -q -W %h:%p gateway.example.com
    #   RekeyLimit 1G 1h
    
    Host *
            SendEnv LANG LC_*
    

    MacOS用root权限sudo vi /etc/ssh/ssh_config才能编辑,更改后如下

    ##Host *
    ##      SendEnv LANG LC_*
    Host *
            XAuthLocation /opt/X11/bin/xauth
    

    相关文章

      网友评论

          本文标题:MacOS与远程Linux的图形程序display问题-XQua

          本文链接:https://www.haomeiwen.com/subject/qjarxktx.html