{"id":47255,"date":"2024-09-20T09:46:11","date_gmt":"2024-09-20T09:46:11","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=47255"},"modified":"2024-09-21T11:09:35","modified_gmt":"2024-09-21T11:09:35","slug":"disable-password-authentication-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2024\/09\/disable-password-authentication-ubuntu\/","title":{"rendered":"Disable Password Authentication Popups in Ubuntu 24.04"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/password-keyring-seahorse.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-46620\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/password-keyring-seahorse-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/password-keyring-seahorse-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/password-keyring-seahorse-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/password-keyring-seahorse-700x700.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/password-keyring-seahorse-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/password-keyring-seahorse.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>When launching some apps (e.g., GParted, Synaptic, or Grub Customizer), install\/uninstall packages with App Center or Software Updater, it always pops-up a dialog asking for admin password to authenticate.<\/p>\n<p>This is great for security! But for <del datetime=\"2024-09-21T11:09:20+00:00\">lazy men<\/del> those who don&#8217;t want to type user password again and again after logged in (or unlocked screen), it may be OK to disable the authentication window when using their computers at home or other safe places.<\/p>\n<div id=\"attachment_47256\" style=\"width: 666px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/password-popup.webp\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-47256\" class=\"size-full wp-image-47256\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/password-popup.webp\" alt=\"\" width=\"656\" height=\"494\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/password-popup.webp 656w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/password-popup-300x226.webp 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a><p id=\"caption-attachment-47256\" class=\"wp-caption-text\">Password Authentication Pop-up in Ubuntu<\/p><\/div>\n<p><!--more--><\/p>\n<p><b>NOTE 1: For security, it&#8217;s NOT recommended to disable the authentication. You MUST know what you&#8217;re going to do, and do it at your own risk!<\/b><\/p>\n<p><b>NOTE 2: This tutorial is tested and works on Ubuntu 24.04 and Debian 12. It should also work in Linux Mint 22, but NOT for Ubuntu 22.04 and earlier.<\/b><\/p>\n<h3>About Polkit:<\/h3>\n<p>Ubuntu and many other Linux use <a href=\"https:\/\/polkit.pages.freedesktop.org\/polkit\/\" target=\"_blank\" rel=\"noopener\">polkit<\/a> for controlling system-wide privileges. It&#8217;s an authentication framework that provides a finer control of access rights for graphical desktop environments.<\/p>\n<p>When a graphical application need to do a registered action that requires admin\/root permission, polkit can control which user (or user in which group) that runs the app is authorized with or without password authentication.<\/p>\n<p>Unlike <code>sudo<\/code> for command line, polkit does not grant root permission to an entire process, but allows specific privileges to a user or group on an as-needed basis.<\/p>\n<p>And, here I&#8217;m going to show you how to configure polkit to disable password authentication for either global or specific actions, when running with certain user or group.<\/p>\n<h3>Option 1: Disable Password Authentication Globally for Certain Users<\/h3>\n<p>NOTE: Option 1 and option 2 do NOT stop your system from asking password when running <code>sudo<\/code> command in terminal. It only works for graphical authentication pop-ups! See option 3 if you need for sudo command.<\/p>\n<p><b>1.<\/b> First, press <code>Ctrl+Alt+T<\/code> on keyboard to open up a terminal window. When it opens, run command create &amp; edit a config file under <code>\/etc\/polkit-1\/rules.d\/<\/code> directory:<\/p>\n<pre>sudo gnome-text-editor \/etc\/polkit-1\/rules.d\/49-nopasswd_global.rules<\/pre>\n<p><i>For non-GNOME desktop, replace <code>gnome-text-editor<\/code> in command with your favorite text editor, or use <code>nano<\/code> that works in most desktops.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/add-polkit-rule.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47257\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/add-polkit-rule-700x215.webp\" alt=\"\" width=\"610\" height=\"187\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/add-polkit-rule-700x215.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/add-polkit-rule-300x92.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/add-polkit-rule.webp 722w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><b>2.<\/b> When file opens, add the lines below and <b>replace user &#8220;ji&#8221; to yours<\/b>:<\/p>\n<pre>\/* Allow members in \"ji\" group to execute any actions\r\n * without password authentication.\r\n *\/\r\npolkit.addRule(function(action, subject) {\r\n    if (subject.isInGroup(\"ji\")) {\r\n        return polkit.Result.YES;\r\n    }\r\n});<\/pre>\n<p>In the code above, it adds a rule for all registered actions, while:<\/p>\n<ul>\n<li><code>subject.isInGroup(\"ji\")<\/code>, means all users in group &#8220;ji&#8221; (user &#8220;ji&#8221; is of course in group &#8220;ji&#8221;). You can add more users into this group for the rule. Or, replace it with <code>subject.user == \"ji\"<\/code>, so it only works for this user only.<\/li>\n<li><code>return polkit.Result.YES;<\/code>, means authorize without any authentication! You may replace <b>YES<\/b> with:\n<ul>\n<li><code>NO<\/code> &#8211; never allowed.<\/li>\n<li><code>AUTH_ADMIN<\/code> &#8211; need to enter admin user password to authenticate.<\/li>\n<li><code>AUTH_SELF<\/code> &#8211; need to enter user&#8217;s own password to authenticate.<\/li>\n<li><code>AUTH_ADMIN_KEEP<\/code> &#8211; similar to <code>AUTH_ADMIN<\/code>, but no need to re-enter the password for a certain duration (usually 5 min) when running same action by same app.<\/li>\n<li><code>AUTH_SELF_KEEP<\/code> &#8211; see <code>AUTH_ADMIN_KEEP<\/code>, though it asks user&#8217;s own password.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>After saved the file (for <code>nano<\/code>, press Ctrl+S to save, then Ctrl+X to exit), the rule should apply immediately!<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/nopasswd-global.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47258\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/nopasswd-global-700x334.webp\" alt=\"\" width=\"610\" height=\"291\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/nopasswd-global-700x334.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/nopasswd-global-300x143.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/nopasswd-global-768x366.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/nopasswd-global.webp 950w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Option 2: Disable Password Authentication for Specific Actions<\/h3>\n<p>For security reason, it&#8217;s not safe to disable the authentication pop-up globally. But it seems less dangerous to disable it for some actions, such as install updates through &#8220;Software Updater&#8221;.<\/p>\n<p><b>1. Find out all registered actions.<\/b><\/p>\n<p>In the case, you need to first find out all the registered actions. They differ depends on your desktop and installed apps.<\/p>\n<p>Most of the polkit actions are defined by the <code>.policy<\/code> files under &#8216;\/usr\/share\/polkit-1\/actions&#8217; directory. To list them, open terminal (Ctrl+Alt+T) and run command:<\/p>\n<pre>pkaction<\/pre>\n<p>Or run <code>pkaction --verbose<\/code> to list more info about the registered actions, thus it can be easier to find out which actions to use in next step.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/list-polkit-actions.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47259\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/list-polkit-actions-700x505.webp\" alt=\"\" width=\"610\" height=\"440\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/list-polkit-actions-700x505.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/list-polkit-actions-300x216.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/list-polkit-actions.webp 706w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><b>2. Create\/Edit polkit config file.<\/b><\/p>\n<p>Like option 1, run command below to create a config file (also replace <code>gnome-text-editor<\/code> accordingly):<\/p>\n<pre>sudo gnome-text-editor \/etc\/polkit-1\/rules.d\/49-nopasswd_limit.rules<\/pre>\n<p>When file opens, add similar lines below:<\/p>\n<pre>\/* Allow members in \"ji\" group to execute the defined actions\r\n * without password authentication.\r\n *\/\r\npolkit.addRule(function(action, subject) {\r\n    if ((action.id == \"org.debian.apt.upgrade-packages\" ||\r\n         action.id == \"org.debian.apt.install-or-remove-packages\" ||\r\n         action.id == \"example.action.remove.if_no_need\" ||\r\n         action.id == \"example.action.remove.if_no_need\") &amp;&amp;\r\n        subject.isInGroup(\"ji\")) \r\n    \r\n    {\r\n        return polkit.Result.YES;\r\n    }\r\n});<\/pre>\n<p>Here in the &#8220;if&#8221; sentence, use <code>action.id == \"xxx.xxx.xxx.xxx\"<\/code> for the actions you want to configure. You can add as more actions as you want, just use <code>||<\/code> (logical OR) to separate them, and include all of them in a round brackets.<\/p>\n<p>Finally, add <code>&amp;&amp; subject.isInGroup(\"ji\")<\/code> or <code>&amp;&amp; subject.user == \"ji\"<\/code> to apply the rule for all the actions you added above running with user &#8220;ji&#8221; or users in group &#8220;ji&#8221;.<\/p>\n<p><b>NOTE: You need to replace action.id values and user &#8220;ji&#8221; accordingly!<\/b><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/nopassword-limit.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47260\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/nopassword-limit-700x362.webp\" alt=\"\" width=\"610\" height=\"315\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/nopassword-limit-700x362.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/nopassword-limit-300x155.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/nopassword-limit-768x397.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/nopassword-limit.webp 950w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>Also, save the file will apply the rule immediately!<\/p>\n<h3>Option 3: Disable password authentication for sudo command<\/h3>\n<p>This is an optional step has nothing to do with <code>polkit<\/code>. <b>Also, it&#8217;s NOT safe, since it grants root permission to the entire command process. With it, even remote SSH login can run sudo command without password!<\/b><\/p>\n<p><b>1.<\/b> First, open terminal (Ctrl+Alt+T) and run the command below to make a backup of sudoers file, by copying it to user home directory:<\/p>\n<pre>sudo cp \/etc\/sudoers ~\/sudoers.bak<\/pre>\n<p><b>2.<\/b> Then, run command to edit the sudoers file:<\/p>\n<pre>sudo visudo<\/pre>\n<p>When file opens in terminal window, scroll down and add the line below:<\/p>\n<p><b>ji ALL=(ALL) NOPASSWD:ALL<\/b><\/p>\n<p>Here, replace <b>ji<\/b> to your username. Finally, press Ctrl+S to save, and Ctrl+X to exit.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/sudoers-ji.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47261\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/sudoers-ji-700x505.webp\" alt=\"\" width=\"610\" height=\"440\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/sudoers-ji-700x505.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/sudoers-ji-300x216.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/09\/sudoers-ji.webp 706w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>When launching some apps (e.g., GParted, Synaptic, or Grub Customizer), install\/uninstall packages with App Center or Software Updater, it always pops-up a dialog asking for admin password to authenticate. This is great for security! But for lazy men those who don&#8217;t want to type user password again and again after logged in (or unlocked screen), [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":46620,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[322,2039],"class_list":["post-47255","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-password","tag-security"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/47255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=47255"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/47255\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/46620"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=47255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=47255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=47255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}