The Public-Key Authentication Wizard automatically uploads each new public key to a remote host of your choise. The wizard lists all existing keys, and you can select a key to upload it also to other remote servers at any time. To access the Public-Key Authentication Wizard, click User Authentication → Keys and Certificates on the tree view.
Google Authenticator provides a two-step authentication procedure using one-time passcodes (OTP). The OTP generator application is available for iOS, Android and Blackberry. Similar to S/KEY Authentication the authentication mechanism integrates into the Linux PAM system. This guide shows the installation and configuration of this mechanism.
For the reverse operation (generating codes compatible with Google Authenticator under Linux) see #Code generation below.
Installlibpam-google-authenticator package. Development version is also available with google-authenticator-libpam-gitAUR.
Usually one demands two-pass authentication only for remote login. The corresponding PAM configuration file is /etc/pam.d/sshd
. In case you want to use Google Authenticator globally you would need to change /etc/pam.d/system-auth
, however, in this case proceed with extreme caution to not lock yourself out.In this guide we proceed with editing /etc/pam.d/sshd
which is most safely (but not necessarily) done in a local session.
To enter both, your unix password and your OTP, add pam_google_authenticator.so
above the system-remote-login lines to /etc/pam.d/sshd
:
This will ask for the OTP before prompting for your Unix password. Changing the order of the two modules will reverse this order.
To allow login with either the OTP or your Unix password use:
Enable challenge-response authentication in /etc/ssh/sshd_config
:
Finally, reload the sshd
service.
AuthenticationMethods
to allow both: two-factor and key-based authentication. See OpenSSH#Two-factor authentication and public keys.Sometimes, we just want to enable the 2FA capability just when we connect from outside our local network.To achieve this, create a file (e.g. /etc/security/access-local.conf
) and add the networks where you want to be able to bypass the 2FA from:
Then edit your /etc/pam.d/sshd
and add the line:
Every user who wants to use two-pass authentication needs to generate a secret key file in his home folder.This can very easily be done using google-authenticator:
It is recommended to store the emergency scratch codes safely (print them out and keep them in a safe location) as they are your only way to log in (via SSH) when you lost your mobile phone (i.e. your OTP-generator). They are also stored in ~/.google_authenticator
, so you can look them up any time as long as you are logged in.
Install a generator application on your mobile phone (e.g.):
Biss key generator software download. In the mobile application, create a new account and either scan the QR code from the URL you were told when generating the secret key file, or enter the secret key (in the example above 'ZVZG5UZU4D7MY4DH') manually.
Now you should see a new passcode token being generated every 30 seconds on your phone.
SSH to your host from another machine and/or from another terminal window:
If you want to change the secret key files' storage path, you can use the flag --secret
:
Then, don't forget to change the location path for PAM, in /etc/pam.d/sshd
:
user=root
is used to force PAM to search the file using root user.
Also, take care with the permissions of the secret key file. Indeed, the file must be only-readable by the owner (chmod: 400
). Here, the owner is root.
The Google Authenticator PAM plugin can also be used for console logins and with GDM. Just add the following to /etc/pam.d/login
or the /etc/pam.d/gdm-password
file:
If you have Google Authenticator configured with other systems, then losing your device can prevent you from being able to log in to those systems. Having additional ways to generate the codes can be helpful.
A script that enables the display, generation, storage and management of google authenticator codes is available from the AUR (gashellAUR). Alternatively there is also auther (auther-gitAUR).
The easiest way to generate codes is with oath-tool
. It is available in the oath-toolkit package, and can be used as follows:
Where ABC123
is the secret key.
On most Android systems with sufficient user access, the Google Authenticator database can be copied off the device and accessed directly, as it is an sqlite3 database. This shell script will read a Google Authenticator database and generate live codes for each key found: