Server Fault is a question and answer site for system and network administrators. 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

I'm connecting to a remote server, but want to make sure that they keys have been created relatively recently. How can I tell when the keys for that ssh server were generated?

If I can't check remotely, is there a way to use tools to check the server's keys age locally?

share|improve this question
Why's it matter? changing the servers key will require you to re-validate for all users. – xenoterracide Nov 13 '09 at 21:00
I was asked to determine how long a particular key on a server had been in place and I couldn't think of a way to know for sure. An SSL certificate is stamped in the certificate itself, for instance (as the example that was given me). The requesting party wanted to know something similar about ssh and I couldn't find a good answer. – Jim Dec 10 '09 at 17:40
up vote 3 down vote accepted

ls -l /etc/ssh/ssh_host* perhaps?

There is no guarantee that they aren't old though.

share|improve this answer
ls -l should do it, but stat will give you modification / creation and access .. better way to gauge, just in case. – Philip Reynolds Nov 13 '09 at 20:20
+1 for use of stat. – egorgry Nov 13 '09 at 20:24
the -al was just habit. I type it so often that I don't even think about it anymore. – Zoredache Nov 13 '09 at 20:55
Might consider aliasing "ls -l[a]" to ll – Nerdling Nov 13 '09 at 20:59

If you are trying to detect someone being nefarious there really isn't anything stopping them from changing the date on those files. The only real way is to keep your own list/database with the key and the date it was added.

Using something with ssh-keyscan you could cook up a pretty quick solution to scan your whole network and store the information into say an sqlite db file with a date.

share|improve this answer

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.