Password for mounting USB sticks and other devices

Found the answer on the internet.

  1. Create a rule in /etc/polkit-1/rules.d/99-udisk2_mount.rules with the following contents:
polkit.addRule(function(action, subject) 
 { 
 polkit.log("action "+ action); 
 polkit.log("subject "+ subject); 
 if (action.id == "org.freedesktop.udisks2.filesystem-mount-system") 
 { 
 return polkit.Result.AUTH_ADMIN
 }; 
 if (action.id == "org.freedesktop.udisks2.filesystem-mount") 
 { 
 return polkit.Result.AUTH_ADMIN; 
 }; 
 if (action.id == "org.freedesktop.udisks2.filesystem-mount-other-seats") 
 { 
 return polkit.Result.AUTH_ADMIN; 
 }; 
 });
  1. Restart the Polkit policies:
systemctl restart polkit
4 Likes