How to troubleshoot a "Not authorized to perform operation" error message when automatically mounting flash drives and other external USB storage devices

botond published 2021/03/30, k - 23:56 time

Content

 

Introductory

When you connect an external USB drive or flash drive to your machine, the Linux system will automatically mount its file system for the appropriate user. However, this automatic mount may fail for some reason and you will get a small window with an "Not authorized to perform operation" error message.

 

 

The symptom

If you connect a USB drive or flash drive, the mount will not happen automatically. In the best case, an authentication window will appear asking for the root password:

Authentication is required to attach the device.

In this case, typing in the root password will of course mount the drive. But that shouldn't be the case.

In worse cases, however, you may immediately reject the attachment with the "Not authorized to perform operation" message in the title:

Attachment failed - Not authorized to perform operation error message

In this case, if you try to mount the device manually with your plain user, the udisksctl command, it will ask for authentication, and after entering the root password, the mount will take place:

==== AUTHENTICATING FOR org.freedesktop.udisks2.filesystem-mount ===
Hitelesítés szükséges a(z) Hitachi HTS545025B9A300 (/dev/sdb1) csatolásához
Authenticating as: root
Password: 
==== AUTHENTICATION COMPLETE ===
Mounted /dev/sdb1 at /media/botond/kulso_250gb

You can only mount a device with root authentication

As you can see in the picture, the block device name appeared, but it did not attach to the / dev / sdb1 tool. Eventually, after entering the root password, access to our storage will appear, but this should go automatically.

 

 

The solutions

There are two solutions to this problem. Let's see them.

Temporarily disable Chrome Remote Desktop

If you do not use the Chrome Remote Desktop application, you can skip this section.

After a little searching, I found some places where this was written to download Chrome Remote Desktop because it interferes with this part. Since I also use this app regularly to access my other machines, I tried it. However, you don't need to uninstall the app itself, just turn off its feature while plugging in your USB storage device:

sudo systemctl stop chrome-remote-desktop.service

Then, after the device has automatically plugged in, we can restart Chrome Remote Control:

sudo systemctl start chrome-remote-desktop.service

Then I have attached any flash drive flawlessly to me. However, after restarting the machine, we need to disable the Chrome remote control again.

If you don’t want to mess with it every day, then come the permanent solution.

Modify the udisks daemon security policy

The second solution is to change the security policy of the udisks daemon. To do this, of course, you must have the udisks2 package installed on your system so that you can use the features of udisks and change your settings.

Open as root for editing a /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy file:

sudo nano /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy

Here we find the rule beginning with the following:

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

And at the bottom of this block, modify the following sections about this:

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

to:

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

Then save the file.

The following USB device will now be connected automatically and the standard "detection" window will appear:

Device successfully connected

 

 

Conclusion

So for me, Chrome Remote Desktop messed things up, but both solutions worked. So if you are using the Chrome remote control, it is better to choose the second solution so that you can avoid this error permanently.