- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- System Administration
- >
- Re: Discover PC ip address via putty when connecte...
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- Report Inappropriate Content
04-04-2011 05:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP