# [Solved] How is "DISPLAY" env variable set when using SSH?

## solamour

I just noticed that when I SSH to my machine with "ssh -X gentoo_server", then the environment value for "DISPLAY" is magically set to "localhost:10.0". If I open another SSH session without closing the first one, "DISPLAY" is set to "localhost:11.0".

That's all fine and dandy, because all my X apps work correctly no matter which terminal I run them from. I'd like to know how "DISPLAY" set with correct values. I mean, does "gentoo_server" keep track of how many sessions I have open and assign different values for "DISPLAY"?

__

solLast edited by solamour on Wed Mar 02, 2011 11:25 pm; edited 1 time in total

----------

## Yamakuzure

The server does it on its own: *http://www2.lns.mit.edu/compserv/security/ssh.html#x11 wrote:*   

> If you enable X11 forwarding and you ssh to a remote host, ssh will set the DISPLAY environment variable to something like DISPLAY=remotehost:11.0. All X11 applications which you start on remotehost will connect to the X11 port remotehost:11.0. SSH will then forward all X11 traffic to your local display using the encrypted link between the hosts.

 Edit: And yes, the ssh server keeps track of this.

----------

## solamour

That says it all. Thank you for the clear explanation.

__

sol

----------

