Determining Local IP Address within .profile

Kevin Steves
Thu, 05 Sep 2002 19:15:02 -0000

On Wed, Sep 04, 2002 at 02:41:45PM +0100, Mario Paumann
wrote:
> I haven't found an easy solution to determine the local IP to which the
remote SSH client is connected to the local SSHD. We use MC/Serviceguard which
can create many Interfaces where a remote client could connect and we like to
know within .profile which interface the client has connected to.
>
> I've looked at the sourcecode and maybe the following could do
something I described :
>
> session.c:871 RCSID("$OpenBSD: session.c,v 1.142 2002/06/26 13:49:26
deraadt Exp $");
> do_setup_env
>
>         child_set_env(&env, &envsize, "SSH_LOCAL_IP",
get_local_ipaddr(packet_get_connection_in());
>
> what do you think of it ?

I agree this is useful.
See also: http://bugzilla.mindrot.org/show_bug.cgi?id=384

I would perhaps be better if this all were exposed in just one environment
variable, e.g.,
SSH_CONNECTION=172.31.1.53 14932 192.168.1.9 24

and deprecate SSH_CLIENT, but adding SSH_SERVER as in 384 may be
less confusing.