Search code examples
cauthenticationsshpamsshd

How do I give the user a customized error code/block reason with a custom pam ssh module?


I wrote a pam_module whichs does a couple of things and became to huge to post any code here. It basically works similar to pam_abl but with a couple of additional features like City/Country based blocking as well as checking with a dns blacklist.

Now I want to give the user a reason why his login was not successful. Something like: login failed because your country is blocked.

I hope you get the idea. Although I did some research I did not find a possibility yet to do this in pam_auth. I hope someone can give me a hint and/or lead me in the right direction. Thanks in advance.

Edit: For anyone else with a similar problem: pam_info is what you are looking for.


Solution

  • Source code of pam_motd(8) or should give you some idea how to write back to the user.

    Actually, there is function pam_info(3), which does exactly what you want.