Back to Home

Redirecting an X11 Session through ssh on Mac OS X

mac os x · ssh · x11

Redirecting an X11 Session through ssh on Mac OS X

    It is no secret that working on a desktop with Linux and, if necessary, running a graphical program on a remote server, the set of actions is extremely simple:
    kostik@kostik: ~> ssh -X 192.168.1.2

    However, working on a Mac there are several additional steps that must be taken to make everything as simple as that.
    1) If you do not have X11 (and you can check this by looking at / Applications / Utilities / for the presence of the X11.app application there, or through the spotlight, which is much faster :)), then you can install it from the Mac OS X installation disc from additional packages.
    2) Before entering the remote server in order to start the graphical application, it is necessary that X11 have already been launched.
    3) It is also necessary that the DISPLAY environment variable be set to: 0.0 (in the Mac OS, by default, when opening, DISPLAY is set to something like / tmp / launch-CjJQkr /: 0)

    You can do this, more precisely, points 2 and 3, repeat each time. Or you can register an alias in your .bash_profile
    alias sshx='export DISPLAY=:0.0 && open /Applications/Utilities/X11.app && ssh -X'
    once : after which, without thinking about configuring and starting X11, connect to the server:
    kostik@kostik: ~> sshx 192.168.1.2

    Just in case, I will clarify that this alias sets the environment variable $ DISPLAY, then opens the X11 application and executes the ssh -X command with further command line parameters, in this case it is the IP server.

    That's all sobsno.
    I hope someone comes in handy.

    Read Next