📜 ⬆️ ⬇️

X11 session redirection via ssh on Mac OS X

It’s no secret that working on a desktop with Linux, and if necessary running a remote graphic 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 has a few extra steps that need to be done to make it as simple as that.
1) If you don’t have X11 (you can check it by looking at / Applications / Utilities / for the presence of X11.app application there, or through spotlight, which is much faster :)), then you can install it from the Mac OS X installation disc additional packages.
2) Before entering a remote server in order to launch a graphical application, it is necessary that X11 are already running.
3) It is also necessary that the DISPLAY environment variable be set to: 0.0 (in Mac OS, by default when opening the shell, DISPLAY is set to something like / tmp / launch-CjJQkr /: 0)

You can do it all, more precisely points 2 and 3, to do it again each time. And you can once register an alias in your .bash_profile:
alias sshx='export DISPLAY=:0.0 && open /Applications/Utilities/X11.app && ssh -X'
after that, without thinking about setting up and running X11, connect to the server:
kostik@kostik: ~> sshx 192.168.1.2

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

That is all.
I hope someone will come in handy.

')

Source: https://habr.com/ru/post/84061/


All Articles