I was following along with 2 guides for my new Raspberry pi 4b. To get ssh setup and MFA. I've included the link for the MFA as this appears to be where I'm having an issue.

My issue is that when I use CMD from my laptop and run

ssh username@ip_address

It prompts me for the user's password and then for the 6 digit code in my case I'm using google Authenticator. So I know SSH and the MFA work. However, when I try to ssh using putty I can sign in but it doesn't prompt for a 6 digit code? Is there something else I need to do to get the 6 digit code? As this is the main device I'll be connecting to with my RPI 4B I do have the Private key file for authentication attached. I don't think that would make a difference either way.



1 Answer 1


So to get putty to use the MFA(google authenticator) I had to:

Modify the SSH daemon configuration.

sudo nano /etc/pam.d/sshd

In this locate(was towards the top for me) "@include common-auth" Comment this out by just putting "#" in front Ctrl + x press y and hit enter to save

then modify the SSH configuration file to tell ssh that it needs to ask for 2fa code.

sudo nano /etc/ssh/sshd_config

at the bottom of this file I added "AuthenticationMethods publickey, keyboard-interactive" ctrl + x press y and enter to save

next restart the ssh daemon

sudo systemctl restart sshd

Finally, I tested again to be sure with Putty, CMD, and Termius. Putty and Termius tested with no issues each requesting the google authenticator and the users password. When I try to run:

ssh usernam@ip_address

I get permission denied.

if I remove AuthenticationMethods publickey,keyboard-interactive and restart the sshd it works on cmd but not the other two.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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