Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
2  
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
add comment

2 Answers 2

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
3  
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
2  
+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
add comment

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
add comment

Your Answer

 
discard

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.