{"id":13652,"date":"2020-11-02T13:29:58","date_gmt":"2020-11-02T12:29:58","guid":{"rendered":"https:\/\/www.credativ.de\/blog\/credativ-inside\/two-factor-authentication-for-openssh-and-openvpn\/"},"modified":"2020-11-02T13:29:58","modified_gmt":"2020-11-02T12:29:58","slug":"two-factor-authentication-for-openssh-and-openvpn","status":"publish","type":"post","link":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/","title":{"rendered":"Two-Factor Authentication for OpenSSH and OpenVPN"},"content":{"rendered":"<p>Authentication using username and password still represents the standard procedure for most applications to authenticate to a service. However, the use of a second factor is becoming increasingly widespread and is even <a href=\"https:\/\/www.bsi-fuer-buerger.de\/BSIFB\/DE\/DigitaleGesellschaft\/OnlineBanking\/Zwei_Faktor_Authentisierung\/Zwei-Faktor-Authentisierung_node.html\" target=\"_blank\" rel=\"noopener noreferrer\">recommended<\/a> by the BSI, the German Federal Office for Information Security. While not mandatory, various web services at least offer the option to enable two-factor authentication (2FA) for a user account.  <\/p>\n<p>However, not only the security of web services can be enhanced using 2FA\u2014classic services such as SSH also allow the use of a second factor alongside the usual authentication methods such as passwords or certificates.<\/p>\n<h2 id=\"verfahren\">Methods<\/h2>\n<p>The most widely used method for one-time passwords as a second factor is probably TOTP, the Time-Based One-Time Password. The method is standardized in <a href=\"https:\/\/tools.ietf.org\/html\/rfc6238\" target=\"_blank\" rel=\"noopener noreferrer\">RFC6238<\/a> and is sometimes also known as <em>Google Authenticator<\/em>. <\/p>\n<p>With TOTP, a numeric <em>one-time password<\/em> (OTP) valid for a short period is calculated from the current time and the <em>shared secret<\/em>, a secret known to both the service and the user.<\/p>\n<p>Typically\u2014and fixed in the case of Google Authenticator\u2014the password consists of 6 digits and has a validity period of 30 seconds. However, the standard also provides for other lengths and time periods. <\/p>\n<p>For calculating the OTP, there are CLI applications such as <code>oathtool<\/code> as well as GUI applications such as <code>KeePassXC<\/code> or smartphone apps such as <code>AndOTP<\/code>.<\/p>\n<h2 id=\"einrichtung\">Setup<\/h2>\n<p>PAM (Pluggable Authentication Modules) is a collection of libraries that allows applications and services to delegate user authentication instead of having to implement it themselves. For this purpose, the messages exchanged during authentication between PAM and the user are forwarded through the application to the respective recipient. <\/p>\n<p>During this conversation, PAM processes the modules configured in the application&#8217;s service file, in which the respective authentication methods are implemented. PAM ultimately reports only success or failure of the authentication to the application itself. <\/p>\n<p>To use one-time passwords under Linux, the PAM module  <a href=\"https:\/\/www.nongnu.org\/oath-toolkit\/pam_oath.html\" target=\"_blank\" rel=\"noopener noreferrer\"><code>pam_oath<\/code><\/a>  is recommended. All services that use <a href=\"http:\/\/www.linux-pam.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">PAM<\/a> to authenticate their users can thus be easily extended with two-factor authentication functionality. These include not only system internals such as <code>login<\/code>, <code>su<\/code>, or <code>sudo<\/code>, but also network-accessible services such as <code>SSH<\/code> or <code>OpenVPN<\/code>.  <\/p>\n<p>Depending on the distribution used, the PAM module is located in the package <code>libpam-oath<\/code> (Debian etc.) or <code>pam_oath<\/code> (CentOS etc.) and can be installed from the official sources.<\/p>\n<h2 id=\"pam\">PAM<\/h2>\n<p>To set up TOTP for SSH, the corresponding PAM <a href=\"http:\/\/www.linux-pam.org\/Linux-PAM-html\/sag-configuration-file.html\" target=\"_blank\" rel=\"noopener noreferrer\">service file<\/a> must be modified. This is located at <code>\/etc\/pam.d\/sshd<\/code>. <\/p>\n<p>This file is approximately 50 lines long and describes, among other things, how a user&#8217;s identity can be verified when logging in via SSH and what environment is created before calling their login shell.<\/p>\n<p>The exact function of the individual entries would exceed the scope of this article. The only line of interest for setting up TOTP is <\/p>\n<pre>@include common-auth<\/pre>\n<p>This adopts the default system behavior defined in the service file <code>\/etc\/pam.d\/common-auth<\/code>: using the module <code>pam_unix<\/code>, the user&#8217;s password is compared with that in <code>\/etc\/shadow<\/code>.<\/p>\n<p>To require verification of an OTP using <code>pam_oath<\/code>, the following line is added directly below the above <code>@include<\/code> directive:<\/p>\n<pre>auth required pam_oath.so usersfile=\/etc\/users.oath digits=6 window=2<\/pre>\n<p>The parameter <code>usersfile<\/code> refers to a file in which the users&#8217; shared secrets are stored, <code>digits=6<\/code> sets the length of the OTP to 6 digits.<\/p>\n<p>Using <code>window=2<\/code> enlarges the window of allowed OTPs. With a window size of 2, in addition to the currently valid OTP, the passwords from the previous and next time period are also valid. While a window size of 0 only allows the current OTP, an increasing number allows one more future and one more past password respectively. Additional parameters can be found in the module&#8217;s <a href=\"https:\/\/www.nongnu.org\/oath-toolkit\/pam_oath.html\" target=\"_blank\" rel=\"noopener noreferrer\">documentation<\/a>.   <\/p>\n<p>The <a href=\"https:\/\/code.google.com\/archive\/p\/mod-authn-otp\/wikis\/UsersFile.wiki\" target=\"_blank\" rel=\"noopener noreferrer\">structure<\/a> of the <em>usersfile<\/em> follows the <a href=\"http:\/\/www.catb.org\/~esr\/writings\/taoup\/html\/ch05s02.html#id2907428\" target=\"_blank\" rel=\"noopener noreferrer\">*NIX tradition<\/a>: each line represents an entry containing multiple fields separated by one or more spaces. While an entry can contain up to nine fields, only the first four are relevant when setting up a new user. They contain, in order: the method used, the username, an optional PIN, and in the last field the shared secret.  <\/p>\n<p>The RFC recommends a 160-bit (i.e., 20-byte) random number as the shared secret. This can easily be created using the <code>openssl<\/code> program: <\/p>\n<pre>$ openssl rand -hex 20<\/pre>\n<p>The output is the 40-character <a href=\"https:\/\/tools.ietf.org\/html\/rfc4648#section-8\" target=\"_blank\" rel=\"noopener noreferrer\">Base16<\/a>-encoded representation of the randomly generated string, for example <em>e2e36e1f3010bba83fed4118244f85be1cbb23fd<\/em>.<\/p>\n<p>To append an entry for the user <em>alice<\/em> using the <em>TOTP<\/em> method with a validity period of 30 seconds to the usersfile, the following command line can be used. The call to openssl contained in <code>$()<\/code> is replaced by its output, the 20-byte shared secret. <\/p>\n<pre>$ echo \"HOTP\/T30 alice - $(openssl rand -hex 20)\" | tee -a \/etc\/users.oath<\/pre>\n<p>The program <code>tee<\/code> outputs the generated entry including the shared secret on the command line and also appends it as an additional line to the usersfile <code>\/etc\/users.oath<\/code>:<\/p>\n<pre>$ echo \"HOTP\/T30 alice - $(openssl rand -hex 20)\" | tee -a \/etc\/users.oath\nHOTP\/T30 alice - e2e36e1f3010bba83fed4118244f85be1cbb23fd<\/pre>\n<h3 id=\"ssh\">SSH<\/h3>\n<p>An OpenSSH configured with default settings authenticates users using the built-in  <code>PasswordAuthentication<\/code>. To use PAM, this must be disabled and <code>ChallengeResponseAuthentication<\/code> enabled instead. Authentication via PAM is then activated using the parameter <code>UsePAM<\/code>. <\/p>\n<p>The configuration file <code>\/etc\/ssh\/sshd_config<\/code> must therefore contain the following lines:<\/p>\n<pre>PasswordAuthentication no\nChallengeResponseAuthentication yes\nUsePAM yes<\/pre>\n<h4 id=\"demo\">Demo<\/h4>\n<p>Due to the changes to the OpenSSH configuration, the prompt that requests password entry during connection establishment has changed.<\/p>\n<p>The <em>PasswordAuthentication<\/em> built into OpenSSH displayed the username and hostname used for the connection in the prompt.<\/p>\n<pre>alice@local$ ssh alice@192.0.2.1\nalice@192.0.2.1's password:\nalice@remote$<\/pre>\n<p>After switching to PAM using <em>ChallengeResponseAuthentication<\/em>, the input prompt of the respective PAM module is displayed: first <em>pam_unix<\/em>, then <em>pam_oath<\/em>.<\/p>\n<pre>alice@local$ ssh alice@192.0.2.1\nPassword:\nOne-time password (OATH) for `alice':\nalice@remote$<\/pre>\n<h3 id=\"openvpn\">OpenVPN<\/h3>\n<p>OpenVPN classically authenticates users via certificates validated by a trusted, often local, CA. However, during the connection establishment process, it is also possible to query a username and associated password on the client side and verify them on the server side. <\/p>\n<p>To add 2FA to an existing OpenVPN installation, only a few changes to the configuration files are required.<\/p>\n<p>To enable OpenVPN to delegate authentication of the username and password to PAM, the PAM plugin included in the standard installation is entered in the server&#8217;s OpenVPN configuration:<\/p>\n<pre>plugin \/usr\/lib\/openvpn\/openvpn-plugin-auth-pam.so openvpn<\/pre>\n<p>The parameter <code>openvpn<\/code> corresponds to the name of the PAM service file in <code>\/etc\/pam.d\/<\/code>, which must be newly created:<\/p>\n<pre>auth required pam_oath.so usersfile=\/etc\/users.oath digits=6 window=2\n@include common-account<\/pre>\n<p>If there are no user accounts on the machine running the OpenVPN service, their existence check can be skipped with a modified service file:<\/p>\n<pre>auth required pam_oath.so usersfile=\/etc\/users.oath digits=6 window=2\naccount required pam_permit.so<\/pre>\n<p>The module <code>pam_permit<\/code> always returns <em>success<\/em>. Since it is the only specified module of type <em>auth<\/em>, only its result is evaluated. <\/p>\n<p>On the client side, only the following line needs to be added to the configuration so that the user is prompted for their username and (one-time) password during connection establishment:<\/p>\n<pre>auth-user-pass<\/pre>\n<p>If the connection is configured on the client side via a GUI such as NetworkManager, under <em>Connection type<\/em>, instead of the usual setting <em>Certificates (TLS)<\/em>, the entry <em>Password with certificates (TLS)<\/em> must be selected. Under <em>Username<\/em>, the username to be used is entered, but the <em>Password<\/em> field remains empty; the option <em>Ask for this password every time<\/em> must be selected there. <\/p>\n<h4 id=\"demo-1\">Demo<\/h4>\n<p>After adjusting the configuration on the client, the user is prompted to enter a username and the associated OTP during the TLS negotiation of the connection establishment, immediately after certificate verification.<\/p>\n<pre># openvpn client.conf\n...\nEnter Auth Username: alice\nEnter Auth Password: ******\n...<\/pre>\n<p>Even when using NetworkManager, the user is prompted for the current one-time password during connection establishment.<\/p>\n<figure><a href=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/nm-passwort-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/nm-passwort-1.png\" alt=\"IMG OTP query during connection establishment\" width=\"360\" height=\"160\"><\/a><figcaption>OTP query during connection establishment<\/figcaption><\/figure>\n<h2 id=\"otp-berechnen\">Calculate OTP<\/h2>\n<p>The shared secret, or <em>shared secret<\/em>, must\u2014as the name suggests\u2014be known to both sides. On the server side, it is located in the usersfile; on the client side, there are various ways for the user to store the shared secret in order to calculate an OTP. <\/p>\n<p>The shared secret required for calculation was generated with the <code>openssl<\/code> call listed above and output in hexadecimal representation or Base16-encoded. In addition to Base16, representation in Base32 is also common, so care must be taken as to which encoding a program expects when entering the shared secret. Both mentioned methods are described and standardized in <a href=\"https:\/\/tools.ietf.org\/html\/rfc4648\" target=\"_blank\" rel=\"noopener noreferrer\">RFC 4648<\/a>.  <\/p>\n<p>While the tools <code>base32<\/code> and <code>base64<\/code> for Base32 and Base64 respectively are already included in the package <code>coreutils<\/code>, another tool must be installed for converting from Base16, for example <code>basez<\/code>. In addition to the main application <code>basez<\/code>, several symbolic links to it are also created, including <code>base16<\/code>, which can be used like <code>base32<\/code> and <code>base64<\/code>. <\/p>\n<p>To convert the shared secret generated above for <em>alice<\/em> from Base16 to Base32, the following call is sufficient. The option <code>-d<\/code> when calling <code>base16<\/code> stands for <em>decode<\/em>, since the conversion is from Base16. <\/p>\n<pre>$ echo e2e36e1f3010bba83fed4118244f85be1cbb23fd | base16 -d | base32\n4LRW4HZQCC52QP7NIEMCIT4FXYOLWI75<\/pre>\n<p>In Base32 encoding, the shared secret is <em>4LRW4HZQCC52QP7NIEMCIT4FXYOLWI75<\/em>.<\/p>\n<p>As expected, there are also numerous web-based tools online for converting between the various encodings. However, transmission to websites is not recommended: <strong>even a shared secret is a secret<\/strong> and should not be disclosed to third parties! <\/p>\n<p>The situation is similar when using QR codes, which will be covered in a separate article. Although widely used, their use is not without risks that should be analyzed and minimized beforehand. <\/p>\n<h3 id=\"cli\">CLI<\/h3>\n<p>The program  <code>oathtool<\/code>  enables the calculation of OTP on the command line. To calculate TOTP, it is passed the argument <code>--totp<\/code> and the shared secret in Base16 encoding when called: <\/p>\n<pre>$ oathtool --totp e2e36e1f3010bba83fed4118244f85be1cbb23fd<\/pre>\n<p><code>oathtool<\/code>  assumes an OTP length of 6 digits and a window of 0. These assumptions can be adjusted with the arguments <code>-d<\/code> (Digits) and <code>-w<\/code> (Window). <\/p>\n<p>If the shared secret is Base32-encoded, the argument <code>-b<\/code> must be prepended:<\/p>\n<pre>$ oathtool --totp -b 4LRW4HZQCC52QP7NIEMCIT4FXYOLWI75<\/pre>\n<h3 id=\"gui\">GUI<\/h3>\n<p>In addition to securely storing static passwords, KeepassXC also offers the ability to generate one-time passwords according to TOTP. For this purpose, the shared secret is stored as an attribute of an entry. <\/p>\n<p>The shared secret can be added to an existing entry as a <em>key<\/em> by right-clicking and selecting <em>Time-based One-Time Password (TOTP) &gt; Set up TOTP\u2026<\/em>. <em>RFC 6238 token standard settings<\/em> assumes a length of 6 digits and a validity of 30 seconds. The Base16-encoded shared secret is expected as the key. <\/p>\n<figure><a href=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/TOTP_einrichten-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/TOTP_einrichten-1.png\" alt=\"Call: Set up TOTP\" width=\"787\" height=\"338\"><\/a><figcaption>Call: Set up TOTP<\/figcaption><\/figure>\n<figure><a href=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/TOTP_einrichten_dialog-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/TOTP_einrichten_dialog-1.png\" alt=\"Dialog: Set up TOTP\" width=\"358\" height=\"364\"><\/a><figcaption>Dialog: Set up TOTP<\/figcaption><\/figure>\n<p>By right-clicking on the entry, the current one-time password can be displayed via <em>Time-based One-Time Password (TOTP) &gt; Show TOTP<\/em>, or copied to the clipboard via <em>Copy TOTP<\/em>.<\/p>\n<figure><a href=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/TOTP_anzeigen-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/TOTP_anzeigen-1.png\" alt=\"Call: Show TOTP\" width=\"606\" height=\"293\"><\/a><figcaption>Call: Show TOTP<\/figcaption><\/figure>\n<figure><a href=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/TOTP_anzeigen_dialog-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/TOTP_anzeigen_dialog-1.png\" alt=\"Dialog: Show TOTP\" width=\"301\" height=\"254\"><\/a><figcaption>Dialog: Show TOTP<\/figcaption><\/figure>\n<h2 id=\"smartphone-app\">Smartphone App<\/h2>\n<p>To calculate a TOTP on a smartphone, <a href=\"https:\/\/github.com\/andOTP\/andOTP\" target=\"_blank\" rel=\"noopener noreferrer\">andOTP<\/a> is recommended. The app is free software, licensed under the MIT License, and can be easily installed via <a href=\"https:\/\/f-droid.org\/de\/packages\/org.shadowice.flocke.andotp\/\" target=\"_blank\" rel=\"noopener noreferrer\">F-Droid<\/a> or from the <a href=\"https:\/\/play.google.com\/store\/apps\/details?id=org.shadowice.flocke.andotp\" target=\"_blank\" rel=\"noopener noreferrer\">Google Play Store<\/a>. <\/p>\n<p>A new entry can be created via the plus button in the lower right corner of the screen. In addition to the option to scan a QR code, the shared secret can be entered manually via the menu item <em>Enter details<\/em>, along with some settings such as time period, length, or hash algorithm. <\/p>\n<figure><a href=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/andotp_eingabe.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/andotp_eingabe.png\" alt=\"Entering details in andOTP\" width=\"300\" height=\"564\"><\/a><figcaption>Entering details in andOTP<\/figcaption><\/figure>\n<figure><a href=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/andotp_anzeige.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/andotp_anzeige.png\" alt=\"Display of the current TOTP in andOTP\" width=\"300\" height=\"113\"><\/a><figcaption>Display of the current TOTP in andOTP<\/figcaption><\/figure>\n<p>The possibility of reading the shared secret and settings for calculating a TOTP using a QR code will be covered in an upcoming article.<\/p>\n<h2 id=\"fazit\">Conclusion<\/h2>\n<p>The examples presented demonstrate how easy it is to extend even existing services with two-factor authentication using TOTP. It is only necessary to configure the connection to PAM and the use of the <em>pam_oath<\/em> module in the corresponding service file. <\/p>\n<p>The procedure shown is primarily suitable for individual systems with a few user accounts to be secured. More complex installations and other methods for one-time passwords are also possible. <\/p>\n<h2 id=\"unterst\u00fctzung\">Support<\/h2>\n<p>If you require support with the configuration or use of two-factor authentication, our <a href=\"https:\/\/www.credativ.de\/en\/portfolio\/support\/open-source-support-center\/\">Open Source Support Center<\/a> is at your disposal &#8211; if desired, also 24 hours a day, 365 days a year.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Authentication using username and password still represents the standard procedure for most applications to authenticate to a service. However, the use of a second factor is becoming increasingly widespread and is even recommended by the BSI, the German Federal Office for Information Security. While not mandatory, various web services at least offer the option to [&hellip;]<\/p>\n","protected":false},"author":60,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_improvement_type_select":"improve_an_existing","_thumb_yes_seoaic":false,"_frame_yes_seoaic":false,"seoaic_generate_description":"","seoaic_improve_instructions_prompt":"","seoaic_rollback_content_improvement":"","seoaic_idea_thumbnail_generator":"","thumbnail_generated":false,"thumbnail_generate_prompt":"","seoaic_article_description":"","seoaic_article_subtitles":[],"footnotes":""},"categories":[1885],"tags":[1709,1759,1764,1850],"class_list":["post-13652","post","type-post","status-publish","format-standard","hentry","category-howtos-en","tag-2fa-en","tag-openssh-en","tag-openvpn-en","tag-ssh-en"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.6 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Two-Factor Authentication for OpenSSH and OpenVPN - credativ\u00ae<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Two-Factor Authentication for OpenSSH and OpenVPN\" \/>\n<meta property=\"og:description\" content=\"Authentication using username and password still represents the standard procedure for most applications to authenticate to a service. However, the use of a second factor is becoming increasingly widespread and is even recommended by the BSI, the German Federal Office for Information Security. While not mandatory, various web services at least offer the option to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/\" \/>\n<meta property=\"og:site_name\" content=\"credativ\u00ae\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/credativDE\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-02T12:29:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/Zwei-Faktor-Authentisierung-fu\u0308r-OpenSSH-und-OpenVPN-Header.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2500\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jan Bolle\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bollejansson\" \/>\n<meta name=\"twitter:site\" content=\"@credativde\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jan Bolle\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/\"},\"author\":{\"name\":\"Jan Bolle\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#\\\/schema\\\/person\\\/f33560ea675ef6722c4459154b42606e\"},\"headline\":\"Two-Factor Authentication for OpenSSH and OpenVPN\",\"datePublished\":\"2020-11-02T12:29:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/\"},\"wordCount\":1834,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/nm-passwort-1.png\",\"keywords\":[\"2FA\",\"OpenSSH\",\"OpenVPN\",\"SSH\"],\"articleSection\":[\"HowTos\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#respond\"]}],\"copyrightYear\":\"2020\",\"copyrightHolder\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/\",\"name\":\"Two-Factor Authentication for OpenSSH and OpenVPN - credativ\u00ae\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/nm-passwort-1.png\",\"datePublished\":\"2020-11-02T12:29:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/nm-passwort-1.png\",\"contentUrl\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/nm-passwort-1.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Two-Factor Authentication for OpenSSH and OpenVPN\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/\",\"name\":\"credativ GmbH\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Organization\",\"Place\"],\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#organization\",\"name\":\"credativ\u00ae\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/\",\"logo\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#local-main-organization-logo\"},\"image\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#local-main-organization-logo\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/credativDE\\\/\",\"https:\\\/\\\/x.com\\\/credativde\",\"https:\\\/\\\/mastodon.social\\\/@credativde\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/credativ-gmbh\",\"https:\\\/\\\/www.instagram.com\\\/credativ\\\/\"],\"description\":\"Die credativ GmbH ist ein f\u00fchrendes, auf Open Source Software spezialisiertes IT-Dienstleistungs- und Beratungsunternehmen. Wir bieten umfassende und professionelle Services, von Beratung und Infrastruktur-Betrieb \u00fcber 24\\\/7 Support bis hin zu individuellen L\u00f6sungen und Schulungen. Unser Fokus liegt auf dem ganzheitlichen Management von gesch\u00e4ftskritischen Open-Source-Systemen, darunter Betriebssysteme (z.B. Linux), Datenbanken (z.B. PostgreSQL), Konfigurationsmanagement (z.B. Ansible, Puppet) und Virtualisierung. Als engagierter Teil der Open-Source-Community unterst\u00fctzen wir unsere Kunden dabei, die Vorteile freier Software sicher, stabil und effizient in ihrer IT-Umgebung zu nutzen.\",\"legalName\":\"credativ GmbH\",\"foundingDate\":\"2025-03-01\",\"duns\":\"316387060\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"11\",\"maxValue\":\"50\"},\"address\":{\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#local-main-place-address\"},\"geo\":{\"@type\":\"GeoCoordinates\",\"latitude\":\"51.1732374\",\"longitude\":\"6.392010099999999\"},\"telephone\":[\"+4921619174200\",\"08002733284\"],\"contactPoint\":{\"@type\":\"ContactPoint\",\"telephone\":\"08002733284\",\"email\":\"vertrieb@credativ.de\"},\"openingHoursSpecification\":[{\"@type\":\"OpeningHoursSpecification\",\"dayOfWeek\":[\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\"],\"opens\":\"09:00\",\"closes\":\"17:00\"},{\"@type\":\"OpeningHoursSpecification\",\"dayOfWeek\":[\"Saturday\",\"Sunday\"],\"opens\":\"00:00\",\"closes\":\"00:00\"}],\"email\":\"info@credativ.de\",\"areaServed\":\"D-A-CH\",\"vatID\":\"DE452151696\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/#\\\/schema\\\/person\\\/f33560ea675ef6722c4459154b42606e\",\"name\":\"Jan Bolle\",\"description\":\"Jan arbeitet seit 2020 an Projekten des Support\u2013Teams und der Internen IT, nachdem er bereits sein Praktikum im Rahmen seines Informatikstudiums bei credativ absolvierte und auch seine Bachelorarbeit zum Thema Einmalpassw\u00f6rter, Zwei\u2013Faktor\u2013Authentisierung und OpenVPN bei credativ schrieb. Bereits zu Schulzeiten interessierte er sich f\u00fcr Freie Software, Netzwerke und Telekommunikation und richtete zusammen mit Mitsch\u00fclern ein Internetcaf\u00e9 ein, auf dessen Server und Clients Debian GNU\\\/Linux seinen Dienst verrichtete.\",\"sameAs\":[\"https:\\\/\\\/x.com\\\/bollejansson\"]},{\"@type\":\"PostalAddress\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#local-main-place-address\",\"streetAddress\":\"Hennes-Weisweiler-Allee 23\",\"addressLocality\":\"M\u00f6nchengladbach\",\"postalCode\":\"41179\",\"addressRegion\":\"Deutschland\",\"addressCountry\":\"DE\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.credativ.de\\\/en\\\/blog\\\/howtos-en\\\/two-factor-authentication-for-openssh-and-openvpn\\\/#local-main-organization-logo\",\"url\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/credativ-logo-right.svg\",\"contentUrl\":\"https:\\\/\\\/www.credativ.de\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/credativ-logo-right.svg\",\"caption\":\"credativ\u00ae\"}]}<\/script>\n<meta name=\"geo.placename\" content=\"M\u00f6nchengladbach\" \/>\n<meta name=\"geo.position\" content=\"51.1732374;6.392010099999999\" \/>\n<meta name=\"geo.region\" content=\"Germany\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Two-Factor Authentication for OpenSSH and OpenVPN - credativ\u00ae","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/","og_locale":"en_US","og_type":"article","og_title":"Two-Factor Authentication for OpenSSH and OpenVPN","og_description":"Authentication using username and password still represents the standard procedure for most applications to authenticate to a service. However, the use of a second factor is becoming increasingly widespread and is even recommended by the BSI, the German Federal Office for Information Security. While not mandatory, various web services at least offer the option to [&hellip;]","og_url":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/","og_site_name":"credativ\u00ae","article_publisher":"https:\/\/www.facebook.com\/credativDE\/","article_published_time":"2020-11-02T12:29:58+00:00","og_image":[{"width":2500,"height":300,"url":"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/Zwei-Faktor-Authentisierung-fu\u0308r-OpenSSH-und-OpenVPN-Header.jpg","type":"image\/jpeg"}],"author":"Jan Bolle","twitter_card":"summary_large_image","twitter_creator":"@bollejansson","twitter_site":"@credativde","twitter_misc":{"Written by":"Jan Bolle","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#article","isPartOf":{"@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/"},"author":{"name":"Jan Bolle","@id":"https:\/\/www.credativ.de\/en\/#\/schema\/person\/f33560ea675ef6722c4459154b42606e"},"headline":"Two-Factor Authentication for OpenSSH and OpenVPN","datePublished":"2020-11-02T12:29:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/"},"wordCount":1834,"commentCount":0,"publisher":{"@id":"https:\/\/www.credativ.de\/en\/#organization"},"image":{"@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#primaryimage"},"thumbnailUrl":"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/nm-passwort-1.png","keywords":["2FA","OpenSSH","OpenVPN","SSH"],"articleSection":["HowTos"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#respond"]}],"copyrightYear":"2020","copyrightHolder":{"@id":"https:\/\/www.credativ.de\/#organization"}},{"@type":"WebPage","@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/","url":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/","name":"Two-Factor Authentication for OpenSSH and OpenVPN - credativ\u00ae","isPartOf":{"@id":"https:\/\/www.credativ.de\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#primaryimage"},"image":{"@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#primaryimage"},"thumbnailUrl":"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/nm-passwort-1.png","datePublished":"2020-11-02T12:29:58+00:00","breadcrumb":{"@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#primaryimage","url":"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/nm-passwort-1.png","contentUrl":"https:\/\/www.credativ.de\/wp-content\/uploads\/2020\/10\/nm-passwort-1.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.credativ.de\/en\/"},{"@type":"ListItem","position":2,"name":"Two-Factor Authentication for OpenSSH and OpenVPN"}]},{"@type":"WebSite","@id":"https:\/\/www.credativ.de\/en\/#website","url":"https:\/\/www.credativ.de\/en\/","name":"credativ GmbH","description":"","publisher":{"@id":"https:\/\/www.credativ.de\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.credativ.de\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Organization","Place"],"@id":"https:\/\/www.credativ.de\/en\/#organization","name":"credativ\u00ae","url":"https:\/\/www.credativ.de\/en\/","logo":{"@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#local-main-organization-logo"},"image":{"@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#local-main-organization-logo"},"sameAs":["https:\/\/www.facebook.com\/credativDE\/","https:\/\/x.com\/credativde","https:\/\/mastodon.social\/@credativde","https:\/\/www.linkedin.com\/company\/credativ-gmbh","https:\/\/www.instagram.com\/credativ\/"],"description":"Die credativ GmbH ist ein f\u00fchrendes, auf Open Source Software spezialisiertes IT-Dienstleistungs- und Beratungsunternehmen. Wir bieten umfassende und professionelle Services, von Beratung und Infrastruktur-Betrieb \u00fcber 24\/7 Support bis hin zu individuellen L\u00f6sungen und Schulungen. Unser Fokus liegt auf dem ganzheitlichen Management von gesch\u00e4ftskritischen Open-Source-Systemen, darunter Betriebssysteme (z.B. Linux), Datenbanken (z.B. PostgreSQL), Konfigurationsmanagement (z.B. Ansible, Puppet) und Virtualisierung. Als engagierter Teil der Open-Source-Community unterst\u00fctzen wir unsere Kunden dabei, die Vorteile freier Software sicher, stabil und effizient in ihrer IT-Umgebung zu nutzen.","legalName":"credativ GmbH","foundingDate":"2025-03-01","duns":"316387060","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"11","maxValue":"50"},"address":{"@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#local-main-place-address"},"geo":{"@type":"GeoCoordinates","latitude":"51.1732374","longitude":"6.392010099999999"},"telephone":["+4921619174200","08002733284"],"contactPoint":{"@type":"ContactPoint","telephone":"08002733284","email":"vertrieb@credativ.de"},"openingHoursSpecification":[{"@type":"OpeningHoursSpecification","dayOfWeek":["Monday","Tuesday","Wednesday","Thursday","Friday"],"opens":"09:00","closes":"17:00"},{"@type":"OpeningHoursSpecification","dayOfWeek":["Saturday","Sunday"],"opens":"00:00","closes":"00:00"}],"email":"info@credativ.de","areaServed":"D-A-CH","vatID":"DE452151696"},{"@type":"Person","@id":"https:\/\/www.credativ.de\/en\/#\/schema\/person\/f33560ea675ef6722c4459154b42606e","name":"Jan Bolle","description":"Jan arbeitet seit 2020 an Projekten des Support\u2013Teams und der Internen IT, nachdem er bereits sein Praktikum im Rahmen seines Informatikstudiums bei credativ absolvierte und auch seine Bachelorarbeit zum Thema Einmalpassw\u00f6rter, Zwei\u2013Faktor\u2013Authentisierung und OpenVPN bei credativ schrieb. Bereits zu Schulzeiten interessierte er sich f\u00fcr Freie Software, Netzwerke und Telekommunikation und richtete zusammen mit Mitsch\u00fclern ein Internetcaf\u00e9 ein, auf dessen Server und Clients Debian GNU\/Linux seinen Dienst verrichtete.","sameAs":["https:\/\/x.com\/bollejansson"]},{"@type":"PostalAddress","@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#local-main-place-address","streetAddress":"Hennes-Weisweiler-Allee 23","addressLocality":"M\u00f6nchengladbach","postalCode":"41179","addressRegion":"Deutschland","addressCountry":"DE"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.credativ.de\/en\/blog\/howtos-en\/two-factor-authentication-for-openssh-and-openvpn\/#local-main-organization-logo","url":"https:\/\/www.credativ.de\/wp-content\/uploads\/2025\/04\/credativ-logo-right.svg","contentUrl":"https:\/\/www.credativ.de\/wp-content\/uploads\/2025\/04\/credativ-logo-right.svg","caption":"credativ\u00ae"}]},"geo.placename":"M\u00f6nchengladbach","geo.position":{"lat":"51.1732374","long":"6.392010099999999"},"geo.region":"Germany"},"_links":{"self":[{"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/posts\/13652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/users\/60"}],"replies":[{"embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/comments?post=13652"}],"version-history":[{"count":0,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/posts\/13652\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/media?parent=13652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/categories?post=13652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.credativ.de\/en\/wp-json\/wp\/v2\/tags?post=13652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}