{"id":530,"date":"2020-04-29T18:22:34","date_gmt":"2020-04-29T11:22:34","guid":{"rendered":"http:\/\/geeksops.com\/?p=530"},"modified":"2020-10-30T19:38:26","modified_gmt":"2020-10-30T12:38:26","slug":"how-to-enable-two-factor-authentication-on-tacacs-configuration","status":"publish","type":"post","link":"https:\/\/rotreein.com\/?p=530","title":{"rendered":"How to enable Two Factor Authentication on Tacacs configuration"},"content":{"rendered":"\n<p>Previously I have written the article about <strong><a href=\"https:\/\/geeksops.com\/?p=1\">Install tacacs+ on debian<\/a><\/strong> that support for multiple network devices, this now In order to secure remote access connection to several network devices such as Cisco NX-OS, HPE Comware-7, Juniper and Aruba Switch, I will  enable two-factor authentication on tacacs configuration<\/p>\n\n\n\n<p><strong>Requirements<\/strong> :<\/p>\n\n\n\n<ul><li>tacacs+<\/li><li>libpam-google-authenticator<\/li><li>google authenticator apps (on smartphone)<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1002\" height=\"483\" src=\"https:\/\/geeksops.com\/wp-content\/uploads\/2020\/07\/image.png\" alt=\"\" class=\"wp-image-531\" srcset=\"https:\/\/rotreein.com\/wp-content\/uploads\/2020\/07\/image.png 1002w, https:\/\/rotreein.com\/wp-content\/uploads\/2020\/07\/image-300x145.png 300w, https:\/\/rotreein.com\/wp-content\/uploads\/2020\/07\/image-768x370.png 768w\" sizes=\"(max-width: 1002px) 100vw, 1002px\" \/><\/figure>\n\n\n\n<p><strong>Package Installation<\/strong><\/p>\n\n\n\n<p style=\"color:#f3f5f7\" class=\"has-text-color has-background has-small-font-size has-very-dark-gray-background-color\">apt-get install tacacs+ libpam-google-authenticator -y<\/p>\n\n\n\n<p><strong>Tacacs Configuration<\/strong><\/p>\n\n\n\n<pre data-mode=\"typescript\" data-theme=\"github\" data-fontsize=\"14\" data-lines=\"Infinity\" class=\"wp-block-simple-code-block-ace\">host = 192.168.1.11 { key = !!4dm1n!! enable = des ciscoios }\nhost = 192.168.1.12 { key = !!4dm1n!!enable = des junos }\nhost = 192.168.1.13 { key = !!4dm1n!! enable = des aruba }\nhost = 192.168.1.14 { key = !!4dm1n!!* enable = des hpe-comware }\nhost = 192.168.1.15 { key = !!4dm1n!! enable = des nxos }\n\n\ngroup = Administrator {\n default service = permit\n login = PAM\n service = exec {\n priv-lvl = 15\n}\n pap = PAM\n enable = file \/etc\/passwd\n}\n\ngroup = operator  {\t\n default service = deny\n login = PAM\n service = exec { \n priv-lvl = 15\n}\n pap = PAM\n enable = file \/etc\/passwd\n cmd = show {\n permit .*\n }\n cmd = write {\n permit .*\n }\n cmd = copy {\n permit .*\n }\n cmd = exit {\n permit .*\n }\n cmd = display {\n permit .*\n }\n cmd = ping {\n permit .*\n }\n cmd = traceroute {\n permit .*\n }\n cmd = ssh2 {\n permit .*\n }\n cmd = telnet {\n permit .*\n }\n cmd = tracert {\n permit .*\n }\n}\n\nuser = rohmat { member = administrator service = junos-exec { local-user-name = remote-admin }}<\/pre>\n\n\n\n<p><strong>Create tac_plus file on directory \/etc\/pam.d<\/strong><\/p>\n\n\n\n<p style=\"color:#ededed\" class=\"has-text-color has-background has-small-font-size has-very-dark-gray-background-color\">auth requisite pam_google_authenticator.so forward_pass<br>auth required pam_unix.so try_first_pass<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The following step how to create a user on tacacs server manually<\/p>\n\n\n\n<ul><li>Create user account on linux ( tacacs server )<\/li><li>Create user on \/etc\/tacacs+\/tac_plus.conf<\/li><li>Generate OTP on server<\/li><li>Open your\u00a0One Time Password (OTP) app (e.g. Google Authenticator )<\/li><li>Change ownership <strong>.google_authenticator<\/strong> file on each home directory user ( e.g  \/home\/rohmat\/.google_authenticator )<\/li><li>Restart tacacsplus service<\/li><\/ul>\n\n\n\n<p><strong>Create user account on linux<\/strong><\/p>\n\n\n\n<p class=\"has-text-color has-background has-small-font-size has-very-light-gray-color has-very-dark-gray-background-color\">useradd -m rohmat -p $(openssl passwd -1 &#8216;SampleP@sssw0rd!@#&#8217;)<\/p>\n\n\n\n<p><strong>Create user on \/etc\/tacacs+\/tac_plus.conf<\/strong><\/p>\n\n\n\n<p class=\"has-text-color has-background has-small-font-size has-very-light-gray-color has-very-dark-gray-background-color\">user = rohmat { member = netadmin service = junos-exec { local-user-name = remote-admin }}<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Generate OTP<\/strong><\/p>\n\n\n\n<p>By default, the PAM module looks for the secret file in the&nbsp;<strong>.google_authenticator<\/strong>&nbsp;file within the home of the user logging in.<\/p>\n\n\n\n<p style=\"text-align:left\">Put the command \u201c<strong>google-authenticator -s \/home\/rohmat\/.google_authenticator<\/strong>\u201d, that will create<strong> .google_authenticator<\/strong> file on directory \/home\/rohmat\/<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"890\" height=\"439\" src=\"https:\/\/geeksops.com\/wp-content\/uploads\/2020\/07\/image-1.png\" alt=\"\" class=\"wp-image-539\" srcset=\"https:\/\/rotreein.com\/wp-content\/uploads\/2020\/07\/image-1.png 890w, https:\/\/rotreein.com\/wp-content\/uploads\/2020\/07\/image-1-300x148.png 300w, https:\/\/rotreein.com\/wp-content\/uploads\/2020\/07\/image-1-768x379.png 768w\" sizes=\"(max-width: 890px) 100vw, 890px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"807\" height=\"283\" src=\"https:\/\/geeksops.com\/wp-content\/uploads\/2020\/07\/image-2.png\" alt=\"\" class=\"wp-image-540\" srcset=\"https:\/\/rotreein.com\/wp-content\/uploads\/2020\/07\/image-2.png 807w, https:\/\/rotreein.com\/wp-content\/uploads\/2020\/07\/image-2-300x105.png 300w, https:\/\/rotreein.com\/wp-content\/uploads\/2020\/07\/image-2-768x269.png 768w\" sizes=\"(max-width: 807px) 100vw, 807px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Scan QR Code using google authenticator apps<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"199\" height=\"290\" src=\"https:\/\/geeksops.com\/wp-content\/uploads\/2020\/07\/image-3.png\" alt=\"\" class=\"wp-image-542\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Change ownership .google_authenticator file<\/strong><\/p>\n\n\n\n<p>When you log in using user root please change ownership with a user that just created<\/p>\n\n\n\n<p class=\"has-text-color has-background has-small-font-size has-very-light-gray-color has-very-dark-gray-background-color\">chown -R rohmat:rohmat \/home\/rohmat\/.google_authenticator file<\/p>\n\n\n\n<p><strong>Restart tacacs service<\/strong><\/p>\n\n\n\n<p class=\"has-text-color has-background has-small-font-size has-very-light-gray-color has-very-dark-gray-background-color\">systemctl restart tacacs_plus.service<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>ssh login format <\/p>\n\n\n\n<p class=\"has-text-color has-background has-small-font-size has-very-light-gray-color has-very-dark-gray-background-color\">username: your_username<br>password : your_password + OTP<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Previously I have written the article about Install tacacs+ on debian that support for multiple network devices, this now In order to secure remote access connection to several network devices such as Cisco NX-OS, HPE Comware-7, Juniper and Aruba Switch, I will enable two-factor authentication on tacacs configuration Requirements : tacacs+ libpam-google-authenticator google authenticator apps&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,6],"tags":[],"_links":{"self":[{"href":"https:\/\/rotreein.com\/index.php?rest_route=\/wp\/v2\/posts\/530"}],"collection":[{"href":"https:\/\/rotreein.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rotreein.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rotreein.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rotreein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=530"}],"version-history":[{"count":30,"href":"https:\/\/rotreein.com\/index.php?rest_route=\/wp\/v2\/posts\/530\/revisions"}],"predecessor-version":[{"id":573,"href":"https:\/\/rotreein.com\/index.php?rest_route=\/wp\/v2\/posts\/530\/revisions\/573"}],"wp:attachment":[{"href":"https:\/\/rotreein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rotreein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rotreein.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}