Subject: Re: determining originating IP address of current rsh session
To: None <>
From: Wolfgang Rupprecht <>
List: netbsd-users
Date: 03/18/2000 11:28:46 (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
> and I give the command "rsh whatsmyip", it should
> display "". (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 Rupprecht <>
DGPS signals via the Internet