Subject: Re: determining originating IP address of current rsh session
To: None <netbsd-users@netbsd.org>
From: Wolfgang Rupprecht <wolfgang@wsrcc.com>
List: netbsd-users
Date: 03/18/2000 11:28:46
lainestump@rcn.com (Laine Stump) writes:
> I need for a shell script executed by rsh from another machine to tell
> me the IP address of the originating machine. For example, if I'm on
> 10.0.0.1 and I give the command "rsh 192.168.0.1 whatsmyip", it should
> display "10.0.0.1". (In practice I'll use rexec so that the person
> attempting to run the command (from some random IP address) is
> authenticated, but the principle should be the same.
A one-liner that does a getpeername() on fd0 should do the right thing
in cases where you don't have an intervening pty. (Like in the case of
a direct rsh.)
For the pty case (like telnet rlogin ssh) you need the cooperation of
daemon. Both ssh and kerb5's telnetd will propagate some information
for you. (for ssh SSH_CLIENT, for ktelnet DISPLAY). In practice the
DISPLAY is more useful since it will also work correctly in the few
cases where you need to do multi-hop telnets.
> (Oh, and don't bother lecturing me about how I should use ssh -
> everything between the machines is already required to be encrypted and
> authenticated with IPSec. Anyway, the X server I'm using has support for
> rexec, but not ssh.)
ok. s/ssh.*//
-wolfgang
--
Wolfgang Rupprecht <wolfgang+gnus@dailyplanet.wsrcc.com>
http://www.wsrcc.com/wolfgang/
DGPS signals via the Internet http://www.wsrcc.com/wolfgang/gps/dgps-ip.html