2

I have several drives encrypted with VeraCrypt and I wanted to be able to mount them all to automount when I insert a drive containing their keyfiles. This way I only have to decrypt the flash drive that contains the keyfiles and only type in one password. I created an automation program in Nim to handle this: https://github.com/TomAshley303/veramount

My usage is to have my veramount program run on each boot. The problem is that in order to mount a VeraCrypt volume you need to supply a sudo password, so I added VeraCrypt to /etc/sudoers.

However it simply didn't work. Each time my veramount program runs, VeraCrypt isn't given sudo access. If I run veramount from the command line after authenticating to sudo, for instance after running something like sudo ls, it works fine. I thought maybe this was because the calling program (veramount) needed to be added to sudoers but that didn't work either. I wound up with the following:

%veracrypt ALL=(ALL:ALL) NOPASSWD: /usr/bin/veracrypt
%veramount ALL=(ALL:ALL) NOPASSWD: /home/user/Code/nim/mountkey/veramount

Is there something wrong with my sudoers rule? Something must be wrong.

Edit: I realize that in my Nim code I don't use the sudo command to run VeraCrypt. This is because I want my drives to be mounted with permissions for my user account and because when you use VeraCrypt to mount a drive, it automatically prompts you with a popup dialog for your sudo password anyway.

4
  • "in my Nim code, I don't use the sudo command to run Veracrypt" so your problem is solved?
    – strugee
    Jul 16, 2017 at 6:55
  • No, I was just adding that information so that people realize I shouldn't need to use the sudo command.
    – xendi
    Jul 16, 2017 at 11:45
  • 1
    if you don't use sudo what exactly do you think is going to read sudoers?
    – strugee
    Jul 16, 2017 at 11:47
  • Veracrypt requests sudo during its lifecycle (At time of mounting a drive)
    – xendi
    Jul 18, 2017 at 7:54

1 Answer 1

1
%veracrypt ALL=(ALL:ALL) NOPASSWD: /usr/bin/veracrypt
%veramount ALL=(ALL:ALL) NOPASSWD:/home/user/Code/nim/mountkey/veramount

Instead of %veracrypt and %veramount, there should be the name of the user, which should have sudo permission to execute the script. Something like this:

myusername ALL = (root) NOPASSWD: /path/to/my/program

Also make sure this is the last line. Save and exit.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .