SSH X11 Setting the Display Variable

Is there a way to have the DISPLAY variable set the way that sshd sets it when a clientconnects with either -X or -Y option, but after the shell loads? It would be best of thiscould only be done if the shell was started by an ssh session that used the -X or -Y option.
The specific ssh version in question is listed below, but I would like to have solutions fornewer versions of ssh as well.
OpenSSH_4.6p1 Debian-5ubuntu0.6, OpenSSL 0.9.8e 23 Feb 2007

This is the situation. I am running a coLinux based distro named andLinux, which basicallyis Ubuntu 7.04 running parallel with Windows. It has this "hack" that allows X forwardingover a virtual network interface that provides inter OS network between Windows and Linux.The X forwarding is used to load Linux X apps, Xfce based in this case, in Windows usingXming. To make this work, the following line is in /etc/profile.
export DISPLAY=

Early on, I found that this prevented X forwarding to work when I sshed to andLinux via theopen network interface, the interface used to access other computers on my network andthe internet through my firewall. I got around this by adding the following to ~/.profile
export DISPLAY=localhost:10.0

This has 2 issues. The first is that I have to add this for each user. In this case that is nobiggie, but it would be great if I could override this for all users always. The second is oneI found today and that is because I have statically set this variable all ssh sessions use 10and that means that no-matter which ssh session I try to X forward in, the X app is sent tothe computer that crated the first ssh session that successfully had X forwarding set. Therub is that since andLinux "needs" the specific $DISPLAY setting set in /etc/profile, it isinherited by all shell sessions and it gets set after sshd sets this variable. This is a problemfor me as I may be connected from several places with x forwarding enabled. I know I canmanually set this, but that has 2 issues.
1) I have to set it every time.
2) The bigger issue is, I learn nothing by doing that.
So if I were to break down the parts of the $DISPLAY variable in to the following.

x = localhosty = 10z = 0
So I want to be able to set it so that $DISPLAY is set with a different y for each session thatsuccessfully creates an X forwarding session.
Any ideas or hints?
In case it helps.
uname -aLinux andLinux #1 PREEMPT Wed Apr 16 18:50:10 UTC 2008 i686 GNU/Linux

# cat /etc/debian_version lenny/sid
# cat /etc/issue Ubuntu 7.10 \n \l
I have a new version of this andLinux, details below.


Hotmail® has a new way to see what's up with your friends.

Relevant Pages

  • Port Forwarding -- Checking to be sure I understand it
    ... I am providing support for some friends and family (I'm sure everyone knows ... it should let the ssh connection through. ... He's on Windows, and I've just found OpenSSH for Windows ... is there a way to set up this forwarding ...
  • Re: ssh port forwarding
    ... Bernhard Krämer wrote: ... >I am trying to get access to a friends' computer via ssh. ... >computer is behind a router which doesn't support NAT (Network Adress ...
  • ssh port forwarding
    ... I am trying to get access to a friends' computer via ssh. ... computer is behind a router which doesn't support NAT (Network Adress ... Translation). ...
  • Re: Telnet exploit & 3.4-RELEASE
    ... I should have mentioned that about a dozen of my friends use this ... so i need to provide telnet access for them. ... >Many connect from machines where installing an ssh client isn't possible. ...
  • Re: [SLE] Network problem, cannot access own site with url
    ... I can ssh to a friends box and access it remotely. ... WAN Port: ... IP Subnet Mask: ...