Score:0

ssh 2fa not working but works when i sudo

jo flag

I have a problem with the 2FA enabled on my linux.. I made all the required things that are needed to enable the 2FA but i 2FA is not working when i want to connect to the linux OS with ssh. I made the connection with public/private key but the verification with google authentication is not working..

It works when i go and i connect to the PC directly after inserting the password it shows the verification code but when i connect with ssh it does not show the verification code.. After i connect with the private key when i want to execute something with super user privileges it works ( i mean it requires from me to insert the time based code generated in my app).

My question is how to enable the 2FA when i connect to the PC with ssh and private/public key? I mean when i try to login i want to 2FA to show and the be the second security step on my PC. Thank you very much

The linux i use is Ubuntu 22.04

king avatar
jo flag
it is ubuntu 24.04. I guess because the guide was from 2021 something is not working..
king avatar
jo flag
i am sorry it is Ubuntu 22.04.. misclicked when was writing it.. sorry again..
king avatar
jo flag
i guess i have all the needed info.. can we please try to solve my problem?
vidarlo avatar
om flag
Please include *all* relevant parts of the configuration. You have *no* technical information about your configuration, and no log or error messages.
Score:1
jo flag

I resolved my issue. I guess others have this problem also..

Had to add some extra lines to the sshd and sshd_config files to make ssh aware of mfa..

in the file /etc/ssh/sshd_config in the end i had to add auth methods:

AuthenticationMethods publickey,password publickey,keyboard-interactive

Than in the /etc/pam.d/sshd had to comment out the:

@include common-auth

sudo systemctl restart sshd.service

And in the end restart the service and it worked!

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.