Connect with us

Tech

How do I enable Google Authenticator (TOTP) using an SSH key with a passphrase in Debian 12?

How do I enable Google Authenticator (TOTP) using an SSH key with a passphrase in Debian 12?

 


I've installed Debian 12 on a spare Apple Mac Mini and would like to control it over SSH from my iMac. I would like to use an SSH key with a passphrase and also use Google Authenticator for multi-factor authentication.

On the iMac, I created an ssh key with ssh-keygen -t rsa and specified a passphrase, then used ssh-copy-id. [email protected] Copy the public key to the remote Debian server.

Next, I wanted to disable password-only login, so I added the following two lines to the end of /etc/ssh/sshd_config:

Matching user david No password authentication

I then ran systemctl restart sshd and logged out of the remote machine, then tried to log back in and it asked for the passphrase but not the password. So far so good.

Then I followed these two guides to set up Google Authenticator: Guide 1 Guide 2

(I was logged in as the root user so I didn't need to add sudo at the start of everything…)

in particular:

apt install -y libpam-google-authenticator google-authenticator (I answered yes to all 4 questions asked in the Google Authenticator setup) nano /etc/ssh/sshd_config ->Set UsePAM yes ->Added the line “ChallengeResponseAuthentication yes” to the end of the file ->Added the line “AuthenticationMethods publickey,keyboard-interactive” to the end of the file ->Saved and closed /etc/ssh/sshd_config nano /etc/pam.d/sshd ->Commented out the line “@include common-auth” ->Added the line “auth required pam_google_authenticator.so” to the end of the file ->Saved and closed /etc/pam.d/sshd systemctl restart ssh

I then tried to log in in another terminal window on my iMac, but I get the following error:

Received disconnect from 192.168.4.7 port 22:2: No authentication methods enabled

Disconnected from 192.168.4.7 port 22

I was able to revert the changes to the two files and reconnect using only the passphrase, but it doesn't prompt me for the passphrase and Google Authenticator code.

What could be wrong?

I found a similar problem, but the only answer to it doesn't provide enough details.

Next, ensure that your configuration requires PAM authentication (if the public key authentication method is successful, the PAM password authentication part will be skipped). This can be done by setting the appropriate AuthenticationMethods in sshd_config:

Unfortunately it doesn't explain how to “set appropriate AuthenticationMethods in sshd_config”, so that's not very helpful…

thank you.

Complete contents of /etc/ssh/sshd_config:

Include /etc/ssh/sshd_config.d/*.conf KbdInteractiveAuthentication No UsePAM Yes X11Forwarding Yes PrintMotd No AcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server ChallengeResponseAuthentication Yes Match User david PasswordAuthentication No AuthenticationMethods publickey,keyboard-interactive

(There are many other lines that I have omitted because they are commented out).

Complete contents of /etc/pam.d/sshd:

Account required pam_nologin.so @include common-account session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so Close session required pam_loginuid.so Session options pam_keyinit.so Force cancel @include common-session Session options pam_motd.so motd=/run/motd.dynamic Session options pam_motd.so noupdate Session options pam_mail.so Standard noenv # [1]
Session requires pam_limits.so Session requires pam_env.so # [1]
Session required pam_env.so user_readenv=1 envfile=/etc/default/locale session [success=ok ignore=ignore module_unknown=ignore default=bad] Open pam_selinux.so and @include common-password authentication is required pam_google_authenticator.so

(There are a few other lines I've omitted because they are commented out)

Sources

1/ https://Google.com/

2/ https://serverfault.com/questions/1162163/how-do-i-enable-google-authenticator-totp-with-ssh-keys-with-a-passphrase-on-d

The mention sources can contact us to remove/changing this article

What Are The Main Benefits Of Comparing Car Insurance Quotes Online

LOS ANGELES, CA / ACCESSWIRE / June 24, 2020, / Compare-autoinsurance.Org has launched a new blog post that presents the main benefits of comparing multiple car insurance quotes. For more info and free online quotes, please visit https://compare-autoinsurance.Org/the-advantages-of-comparing-prices-with-car-insurance-quotes-online/ The modern society has numerous technological advantages. One important advantage is the speed at which information is sent and received. With the help of the internet, the shopping habits of many persons have drastically changed. The car insurance industry hasn't remained untouched by these changes. On the internet, drivers can compare insurance prices and find out which sellers have the best offers. View photos The advantages of comparing online car insurance quotes are the following: Online quotes can be obtained from anywhere and at any time. Unlike physical insurance agencies, websites don't have a specific schedule and they are available at any time. Drivers that have busy working schedules, can compare quotes from anywhere and at any time, even at midnight. Multiple choices. Almost all insurance providers, no matter if they are well-known brands or just local insurers, have an online presence. Online quotes will allow policyholders the chance to discover multiple insurance companies and check their prices. Drivers are no longer required to get quotes from just a few known insurance companies. Also, local and regional insurers can provide lower insurance rates for the same services. Accurate insurance estimates. Online quotes can only be accurate if the customers provide accurate and real info about their car models and driving history. Lying about past driving incidents can make the price estimates to be lower, but when dealing with an insurance company lying to them is useless. Usually, insurance companies will do research about a potential customer before granting him coverage. Online quotes can be sorted easily. Although drivers are recommended to not choose a policy just based on its price, drivers can easily sort quotes by insurance price. Using brokerage websites will allow drivers to get quotes from multiple insurers, thus making the comparison faster and easier. For additional info, money-saving tips, and free car insurance quotes, visit https://compare-autoinsurance.Org/ Compare-autoinsurance.Org is an online provider of life, home, health, and auto insurance quotes. This website is unique because it does not simply stick to one kind of insurance provider, but brings the clients the best deals from many different online insurance carriers. In this way, clients have access to offers from multiple carriers all in one place: this website. On this site, customers have access to quotes for insurance plans from various agencies, such as local or nationwide agencies, brand names insurance companies, etc. "Online quotes can easily help drivers obtain better car insurance deals. All they have to do is to complete an online form with accurate and real info, then compare prices", said Russell Rabichev, Marketing Director of Internet Marketing Company. CONTACT: Company Name: Internet Marketing CompanyPerson for contact Name: Gurgu CPhone Number: (818) 359-3898Email: [email protected]: https://compare-autoinsurance.Org/ SOURCE: Compare-autoinsurance.Org View source version on accesswire.Com:https://www.Accesswire.Com/595055/What-Are-The-Main-Benefits-Of-Comparing-Car-Insurance-Quotes-Online View photos

ExBUlletin

to request, modification Contact us at Here or [email protected]