15

My Ubuntu 14.04 is asking for my password to mount or unmount an USB stick. How can I change it, so that the mount is automatic and no password input is required ?

This is about mounting arbitrary USB sticks in /media, there is no entry in /etc/fstab. My user is in the 'plugdev' group, but the password prompt is pupping up anyway.

5 Answers 5

13

Try this. Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

sudo gedit /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy

When it opens look for

<action id="org.freedesktop.udisks2.filesystem-unmount-others">
<defaults>
      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
</defaults>

And change it to

<action id="org.freedesktop.udisks2.filesystem-unmount-others">
<defaults>
      <allow_any>yes</allow_any>
      <allow_inactive>yes</allow_inactive>
      <allow_active>yes</allow_active>
</defaults>
11
  • 3
    Follow up question: I see that this string <allow_active>... shows up 29 times in that files - do you recommend to replace them all; if not; which section is the correct one to update?
    – GhostCat
    Jul 29, 2015 at 14:31
  • 1
    Thanks. Please could someone advise if there is a way to edit this in a user-friendly manner? The XML seems to be designed to have a front-end, doesn't it? Aug 13, 2015 at 13:36
  • Also, does anyone know what "attached to another seat means"? I had this problem suddenly. Could it be that ubuntu thinks my drive is in a different "seat"? Aug 13, 2015 at 13:40
  • 2
    When the dialog (for password) is shown, see at "details". It should show something like: "org.freedesktop.udisks2.filesystem-mount". That is the rule you need to change. I had "yes" in "allow_active", so I set "yes" also in the other two (allow_any and allow_inactive). Now the dialog is not shown. BTW, I checked the udisk documentation and found no interface for those options. I agree... there must be one.
    – lepe
    Dec 25, 2015 at 3:25
  • 1
    I'm almost sure, that you could add such rule in /etc/polkit-1/... (see this link: forum.kde.org/viewtopic.php?f=22&t=112092)
    – lepe
    Dec 25, 2015 at 3:28
2

It is not a good solution, to alter .policy files in /usr/share/polkit-1/actions directory, as other answers suggest, since the files may be overwritten on software update. A permanent solution is to create a .pkla file in a sub-directory of /etc/polkit-1/localauthority directory, as man pklocalauthority suggests. While .policy files declare actions and default PolicyKit behavior for them, .pkla files adjust that behavior.

Start editing a new .pkla file:

sudo nano /etc/polkit-1/localauthority/50-local.d/50-easy-mount.pkla

If you only care for local sessions (using local monitor and keyboard), write this:

[Allow local mounting without password]
Identity=unix-group:sudo;unix-group:plugdev
Action=org.freedesktop.udisks2.filesystem-mount
ResultActive=yes

In Debian (and Ubuntu is Debian-based), members of plugdev user group are allowed to mount removable devices and members of sudo are allowed anything. So, you only allow password-less mounting to those who have the rights to mount anyway. (In Ubuntu 20.04 and probably in many other systems, you don't rather need to allow this, as it is already allowed in /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy).

If you wish to also allow mounting in ssh sessions, write this:

[Allow mounting without password]
Identity=unix-group:sudo
Action=org.freedesktop.udisks2.filesystem-mount;org.freedesktop.udisks2.filesystem-mount-other-seat
ResultAny=yes

Here, password-less mounting is granted to admins only (sudo user group), because org.freedesktop.udisks2.filesystem-mount-other-seat action is triggered on mounting attempt by a user who is logged in via ssh and is not logged in locally at the same time. So, mounting with this action potentially allows access to a USB flash drive of another person who is working locally. Change the Identity key to whatever suits your security considerations. For example, to grant password-less mounting to admins and users john and mary, you write:

Identity=unix-group:sudo;unix-user:john;unix-user:mary

Mount like this:

udisksctl mount --options noatime --block-device /dev/sdb1

Unmounting own mounts doesn't ask for password:

udisksctl unmount --block-device /dev/sdb1

See man pklocalauthority, man polkit and man udisksctl for more details. Tested on Ubuntu 20.04.

1

I had the same problem today; "all of a sudden" my 14.04 wanted my password for "everything"; including (un)mount of USB sticks.

I figured that I installed openssh-server in the morning. After removing it, everything is back to normal; I can insert a USB stick; and it is mounted without asking for a password. Strange. Just tried to repro; installed openssh-server again; and no ... no such effect this time.

1

I had the same problem with mounting on one of my systems. I tried using @Mitch approach above which didn't work for me (Although it may work great if you have the unmounting issue) . I took a similar approach to begin with and

sudo gedit /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy

but changed this section

<defaults>
      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>

of

<action id="org.freedesktop.udisks2.filesystem-mount">

to

 <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>

matching content found in the old

/usr/share/polkit-1/actions/org.freedesktop.udisks.policy

Sources: @Mitch answer above

     `/usr/share/polkit-1/actions/org.freedesktop.udisks.policy`

     https://forum.kde.org/viewtopic.php?f=22&t=112092

Testing

0

I also faced this problem two times. Asking for password not only during mount-umnount usb but also during other task like launching any application. I solved it by restarting system. It always worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.