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.

karel
  • 1,961
  • 2
  • 17
  • 26
xendi
  • 603
  • 7
  • 21

1 Answers1

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.

Hunter.S.Thompson
  • 8,839
  • 7
  • 26
  • 41