1

I often work on one of available to me Linux/HP-UX servers (let's say it is server1) and then do ssh server2 ((let's say it is server2)) and start working on another Linux/HP-UX server. Then I can connect another server ((let's say it is server3) and start working on it. While working on server3 how to get in command line information from what server I came from?

So on server3 I want to get information that I came from server2 and on server2 I want to get information that I came from server1? What is a command or utility for it?

migrated from serverfault.com Nov 20 '13 at 16:23

This question came from our site for system and network administrators.

  • 1
    Try who, w, finger, or any of the tools that lists where the current users came from. – MadHatter Nov 20 '13 at 8:36
  • By the way how to show any research efforts? I mean I had done some search on the Internet using this sentence but found nothing useful. Is it OK just to mention that one had done some search on the Internet or it is not enough? – Sergei Kurenkov Nov 20 '13 at 9:29
  • I see on Meta that downvoting on the basis of showing any research efforts is little bit controversial for some people. As for this question putting How to find from what computer I connected to a current server in Google does not give anything about who on the first page. – Sergei Kurenkov Nov 20 '13 at 9:44
  • 1
    Personally, I don't find "it wasn't on the first page on google" to be enough research. Half an hour's searching and reading, that's a bit more like it, and by then you should have found something to tell us about, even if it's not exactly what you wanted. Seriously, it's just a downvote; absorb it, live with it, move on. – MadHatter Nov 20 '13 at 10:08
3

At least for Linux, who <arg> <arg> will display the host you connected from.

$ who hates java
error    pts/3        2013-11-20 08:35 (underground)

The HP/UX man pages indicate the same is true for that operating system. As it should be; I've been using this for decades on a variety of Unixes...

  • Nice - I just had my own Kojak moment, typing "who loves ya" to test it. – MadHatter Nov 20 '13 at 9:14
1

who , whoami and last come to mind but no HPUX athand to test

  • 1
    Just to notice: who am i, not whoami – Sergei Kurenkov Nov 20 '13 at 12:03
1

Besides using who am i:

On Linux (RHEL 6.3)/HP-UX 11.31 ssh sets upon a successful connection several environment variables (ssh client environment variables)

SSH_CONNECTION shows the address of the client, the outgoing port on the client, the address of the server and the incoming port on the server

This is an example:

SSH_CONNECTION='192.168.223.17 36673 192.168.223.229 22'

So it is possible to get this environment variable and then nslookup to get information about a host from the connection was done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.