Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A few weeks ago I made a few ssh connections from my home PC to my college PC and the other way around. Currently I am sitting at my home PC and I am trying to figure out what was the college PC IP address. Any idea where I could find some clues?

I scanned the log files and bash history, but there was nothing obvious there.

I am running Debian Testing.

share|improve this question
For future reference, don't use ssh with an IP address: define an alias with a meaningful name in ~/.ssh/config. – Gilles Jan 30 '12 at 21:50
up vote 4 down vote accepted

If you're lucky, the IP address of the visited hosts can be obtained from ~/.ssh/known_hosts

share|improve this answer
~/.ssh/known_hosts doesn't seem to be human-readable and I can't figure out which bit of it would correspond to an IP address :( – Grzenio Jan 30 '12 at 9:52
What does cat known_hosts | cut -d, -f1 give you? It gives you anything in front of the first comma, which seems to contain this information. – Bernhard Jan 30 '12 at 19:26
@Grzenio Host names in known_hosts are hashed for privacy. You can turn this off from ~/.ssh/config (HashKnownHosts no), but it's too late for old connections. If you suspect that a name or IP address is in there but aren't sure, run ssh-keygen -F tentative-host-name. – Gilles Jan 30 '12 at 21:49

last -n 20 -auser

-n for the 20 most recent logins
-a to have IP at end of line (useful if ipv6)

user to filter the username you want ...

share|improve this answer

A very crude way would be (If it works at all)

history | grep ssh
share|improve this answer
This will only show the last 1000 or so shell-command, so this will probably not help him. – Bernhard Jan 29 '12 at 18:57
Yeah, checked this one before asking the question :( – Grzenio Jan 30 '12 at 9:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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