While working in the shell as a user, if I try the eject command I receive a “Operation not permitted” message. I can do it as “sudo eject”, but that is unsatisfactory. Is there a polkit setting or something I can change/add/adjust to allow me to auto-mount and eject cd/dvds as a regular user?
I tried adding myself to the following groups: wheel, disk, and cdrom. No help.
I also added this line to my /etc/fstab:
/dev/sr0 /run/media/username auto owner,ro,users 0 0
But now I have to mount the drive as root or sudo… no help at all.
I need to do a lot of work with around 100 cdroms and dvds, and I’d like to not have to mount and eject as sudo. Any ideas?
Okay, I think I posted this in the wrong forum. Can anyone at least point out the correct forum to ask this question? The question is more along the lines of: How do I grant the appropriate permissions to a single user to be able to mount the cd-drive, and then to eject the drive.
I know that there are at least eight discs that have files that have malware in them, so I don’t even want to do anything with those discs with super user permissions. But I need to read from all the discs at least once, and many times from the majority of them. And, If I wrote a small application to automate the reading from the discs, how would I grant the app the appropriate rights to “auto mount” the cd-drive, and eject the drive when the app was done with it?
I’m not sure what’s the best forum.
Using KDE/Plasma 5, you should be able to mount/unmount using the device notifier (in the tray). However, that takes mouse clicks. I’m assuming that you really wanted this to be command line.
I’m not sure that it is possible. Mounting/umounting is a root operation. Using the desktop works via some processes that use root in the background.
If I were in your boat, here’s what I would do:
Firstly, I would be using “ssh”. I would add a public/private key to ssh-agent. And I would have added a line to “/root/.ssh/authorized_keys” so that I can then login to root on the basis of the public/private key that ssh-agent holds.
After that, it should need only something like:
ssh root "eject"
to eject a CD.
Well, I’m using LXDE and KDE/Plasma isn’t an option on this machine anymore. Unfortunately.
Using ssh is an interesting option. Probably not the way I’d go, but I’ve filed that away. I know years ago all you had to do was add the user to the correct group(s) and they would have the appropriate rights. The groups still exist, but don’t seem to do anything anymore - at least not for the user.
The best solution would be one that allowed an ordinary user to use a shell program to swap cd/dvds without having to have special privileges or passwords. If they could just be added to a group, or something, that gave them access to a program, and the program had very restricted rights - only enough to mount/umount/eject the cd-drive.
I know I read something about a very similar situation, a few months ago, that was rather complex involving policy kit. I can’t find the discussion again to save my life!
Thanks for the input though.