-
On host A, start up a desktop environment like gnome or window manager like i3, start a terminal, run
echo $DISPLAY
, then you get the display number of this screen, like ":0". -
Open a terminal on host B and ssh to the previous one, run following command:
$ export DISPLAY=:0 $ gvim
Then you can see the gvim open in the screen of the host A.
- In most cases the remote display is ":10". So on host A, if you set DISPLAY as ":10", you will display a GUI window on the screen of host B.
Running the codes below on host A, you can find the display number of hosts ssh to it:
netstat -lnt | awk '
sub(/.*:/,"",$4) && $4 >= 6000 && $4 < 6100 {
print ($1 == "tcp6" ? "ip6-localhost:" : "localhost:") ($4 - 6000)
}'
For example:
localhost:10 ip6-localhost:10
means the remote display is ":10".
Ref:
http://askubuntu.com/questions/47642/how-to-start-a-a-gui-software-on-a-remote-linux-pc-via-ssh
http://unix.stackexchange.com/questions/17255/is-there-a-command-to-list-all-open-displays-on-a-machine