I need a way to obtain a local (not WAN) address of an incoming telnet or ssh session using a shell script or C.
views:
35answers:
1
+1
A:
This can be done in several ways, depending on what OS/ssh daemon/telnet daemon you're using. Here are two approaches:
- OpenSSH publishes the clients ip (and ports) in the environment variable
SSH_CLIENT
. - Use the utmpx database (the same as
who
uses), as explained here: whoamIP - Find hostname/IP of current remote shell user
Anders Lindahl
2010-03-11 20:36:18