- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Discover PC ip address via putty when connecte...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2011 04:19 AM
тАО04-04-2011 04:19 AM
does anyone now how to discover the IP address of the PC via a putty session.
fyi
who -Rmut shows the ip address of the server
lsof -i4 -n | grep .12.175 shows sshd 17663 root 5u IPv4 0xe0004562f53740 0t820190 TCP 10.171.30.133:22->10.141.12.144:63015 (ESTABLISHED)
..I know 10.141.12.144 is my PC and I know 10.171.30.133 is the server in my garage but Id like to know if anyone can connect the out of say netstat/ lsof / who to derive the PC ip address. I used this particular example to highlight the fact that I already know the PC's IP address, I would simply like to find a way of extracting from the putty session.
For the record, "who -uH am i" also shows the server address and not the PC address.
thks
Solved! Go to Solution.
- Tags:
- putty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2011 04:45 AM
тАО04-04-2011 04:45 AM
Re: Discover PC ip address via putty when connected to HPUX server
lsof -i4 -n | grep .12.144 shows sshd 17663 root 5u IPv4 0xe0004562f53740 0t820190 TCP 10.171.30.133:22->10.141.12.144:63015 (ESTABLISHED)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2011 04:51 AM
тАО04-04-2011 04:51 AM
Re: Discover PC ip address via putty when connected to HPUX server
You can get the IP from the syslog.
Rick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2011 05:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2011 05:45 AM
тАО04-04-2011 05:45 AM
Re: Discover PC ip address via putty when connected to HPUX server
echo $SSH_CLIENT gives
10.171.30.133 59241 22...which is the server IP.
Re: syslog ...yes it features in the syslog but the question is how do you discover it via commands. In actual fact its in the results of many outputs and log files but Im trying to extract it from using commands. ...echo $SSH_CLIENT would have been great if it showed the PC ip (and Im sure it does in some cases). If it helps I have a dirty way of finding it via ..
let counter=0
ps -ef | grep `ps | grep -v TTY | sort -u -k2,1 | awk '{ print $2}'` | while read line
do
let NUM=`echo $line | awk '{ print $3 }'`
if [ $counter -eq 0 ]
then
let counter=counter+1
let LAST=$NUM
else
if [ $NUM -lt $LAST ]
then
let LAST=$NUM
fi
fi
done
if [ $NUM -lt $LAST ]
then
let LOWEST=$NUM
else
let LOWEST=$LAST
fi
ps -ef | grep "$LOWEST" | grep -v notty | grep -v grep | grep -v "@" | while read line
do
let var1=`echo $line | awk '{ print $2 }`
if
lsof -i -P | grep "$var1" | grep .com > /dev/null 2>&1
then
lsof -i -P | grep "$var1" | grep .com | awk '{ print $9 }'
fi
done
BUT its neither accurate or guaranteed to produce the correct result.
Please note I added it here merely to highlight what Im looking for ...not for a code critique as that would detract from the actual solution.
Thanks for far .......
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2011 05:48 AM
тАО04-04-2011 05:48 AM
Re: Discover PC ip address via putty when connected to HPUX server
garage_server:22->studypc1.okioc.com:63015
garage_server:22->studypc1.okioc.com:53551
garage_server:22->studypc2.okioc.com:3750
...again ...here ONLY to give an idea of where this should be going ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2011 05:49 AM
тАО04-04-2011 05:49 AM
Re: Discover PC ip address via putty when connected to HPUX server
# echo $SSH_CONNECTION
? this will display both ip addresses, client and server, with the corresponding port numbers.
$SSH_CLIENT should also work, maybe you have opened an ssh session on your server and ssh'ed to localhost. You could check it with a clean start, opening a new connection with putty to your server...
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2011 06:06 AM
тАО04-04-2011 06:06 AM
Re: Discover PC ip address via putty when connected to HPUX server
ahh the joys of "should work".
Remember any good solution should be robust. As it happens, echo $SSH_CONNECTION
shows 10.171.30.133 59241 10.171.30.133 22.
Just to be clear..Im going in via WINSCP,then launching PUTTY.
....again, I stress that:
1. The information is not the mystery. You can get it from syslog, netstat (in a roundabout way), lsof etc.
2. Im looking for a solution that can be run from what ever terminal you choose.
Can we focus in on not what "can" be done, rather the actual question.
Ie. How do you get the IP address of the PC the terminal is connected to using the command tools available. If it isnt possible ..then ok but Im pretty sure there must be a way ...(theres a will after all !)
The dirty code above is a start...it shows my machine as well as another ...i suppose im looking for the "next correct step"
thks again in advance ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2011 07:10 AM
тАО04-04-2011 07:10 AM
Re: Discover PC ip address via putty when connected to HPUX server
or
$> echo $SSH_CLIENT | cut -f1 -d" "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2011 07:53 AM
тАО04-04-2011 07:53 AM
Re: Discover PC ip address via putty when connected to HPUX server
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2011 09:28 PM
тАО04-04-2011 09:28 PM
Re: Discover PC ip address via putty when connected to HPUX server
I purposely left out that I was multi-hopping. I wanted to see if anyone had gotten over that problem. Thanks for all the help. It would be great if a single putty sign-on was all the link there was. Ill leave the thread open for a few days to see if anyone cracks the route back to source for the IP....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2011 05:33 PM
тАО04-05-2011 05:33 PM
Re: Discover PC ip address via putty when connected to HPUX server
TERM=10.11.12.13 telnet nexthop
You'll have to capture $TERM at the top of /etc/profile and save it off for the next hop.
Or run multiple single sessions. I can't tell you how many sysadmins accidentally shutdown the wrong server due to server hopping. I routinely have 5 to 10 PuTTY sessions, all with unique colors using either Connection Manager or Session Manager.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2011 08:05 AM
тАО04-06-2011 08:05 AM
Re: Discover PC ip address via putty when connected to HPUX server
Brilliant.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2011 06:26 PM
тАО04-06-2011 06:26 PM
Re: Discover PC ip address via putty when connected to HPUX server
Any good SA would and should know this. ..and I humbly accept your accolade ;-)