Reputation: 995
I want to verify a user using my Java code. As a choice, I want to check if one knows the password for the account using Java.
I know if I can look into /etc/shadow then it would be easy. However, it looks impossible.
So, is there any way to check if an input password is valid or not for the user's password in Unix system.
I read man password
but I could not find a good solution.
It would hopefully be:
passcheck hogepass -> return 0 if it is true return 1 if not
I think I can use password
somehow but it could be very dangerous..
I want to use the way in Java. So if you have any idea that runs on (only) Java. It is also welcome.
Upvotes: 0
Views: 182
Reputation: 1412
See if this works. ssh to host using the username and password supplied and check for the response. If you get shell prompt then login is successful and credentials are valid. But your program should be trustworthy for users to submit their username and password otherwise this could be a form of phishing.
Upvotes: 1