How to record failed ssh password login attempts?

December 19, 2014 4k views

Not sure exactly how to word the question and therefore cannot find anything about it on Google, but is there a way (in Ubuntu 12.04 - 14.10) to record any failed login attempts that occur over ssh? I'm aware that these sorts of logs are made as my droplet gets attacked every few seconds when fail2ban isn't enabled, but is there a way of seeing what sort of passwords are being guessed?
For example, if my password is abc123, I'll want to change it as soon as possible if they're guessing abc122 but can relax a little if !@!@!@! is what's being guessed. Please let me know if you know how to do this sort of thing, as I'm really curious as to what the bots are trying. For all I know, they could be very close to guessing what I view as a very secure password.

3 Answers

For security reasons sshd does not log the password being used. This is to prevent your legitimate password from being logged if you missed a case, or added a space.

With a standard installation of openssh-server this is not possible and would not generally be recommended as any solution would likely log successful passwords as well and if that could be avoided it would still log legitimate failed attempts (if you were to mix up two characters of your password). That being said I was able to locate a discussion on just this topic on the Ubuntu forums that includes a link to a patch for the ssh server which should make this possible.

  • Ryan, do you have a link to that discussion? I'm very interested and I always copy and paste my password in due to its complexity so making a mistake is impossible, unless I somehow paste in the wrong password, which is unlikely.

Have another answer? Share your knowledge.