0

To secure ssh connections I wrote a script that sent otp code when trying to connect When the user enters his username (login as :) he will receive the mail from the otp

Where should I put my script so that it is executed just before that can enter its password?

enter image description here

2
  • 1
    I think you'd need to edit PAM's login routines, but I've never done this myself. – djsmiley2kStaysInside Jun 15 '17 at 9:31
  • How i can to it ? – Assane Keita Jun 15 '17 at 9:38
0

As per the answer on askUbuntu, you need to use PAM_Exec to achieve this.

You can use PAM for this. The PAM configuration for the SSH service is in /etc/pam.d/sshd. To run a command before anything in the login process, add something like:

auth [default=ignore] pam_exec.so /path/to/some/script
3
  • Thanks for the support djsmiley2k and DavidPostill it is working now – Assane Keita Jun 15 '17 at 9:57
  • Awesome :) I like the idea of what you've mentioned, maybe you can document it somewhere so I can look at implementing it myself? – djsmiley2kStaysInside Jun 15 '17 at 10:02
  • No worries I would do the necessary I'll send it to you – Assane Keita Jun 15 '17 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.