okay, played around, and think I kinda got somewhere…
What I did on my holidays
as root, created partition in fdisk
fdisk /dev/sdz
n
[enter]
+100G
w
so root created /dev/sdz5, then encrypt the blank partition
root@redripper:~/root# cryptsetup -v luksFormat /dev/sdz5
set it with a phrase from password generator
root@redripper:~/root# cryptsetup luksAddKey /dev/sdz5
ran this twice, to add 2 additional passphrases as keys
root@redripper:~/root# cryptsetup open /dev/sdz5 lukszy
"Enter passphrase for /dev/sdz5:"
Used the third key for this, but all should be interchangeable
lsblk
└─sdz5 65:149 0 100G 0 part
└─lukszy 253:0 0 100G 0 crypt
root@redripper:~/root# mkfs.exfat /dev/mapper/lukszy
Creating exFAT filesystem(/dev/mapper/lukszy, cluster size=131072)
Writing volume boot record: done
..
exFAT format complete!
root@redripper:~/root# mount /dev/mapper/lukszy /mnt/lukzyPlace/
then testing as user…
trooper_ish@redripper:~/notes$ echo testymctest >> /mnt/lukzyPlace/tesfile0
bash: /mnt/lukzyPlace/tesfile0: Permission denied
okay, so normal user, was unable to write to the new encrypted device…
trooper_ish@redripper:~/notes$ sudo umount /mnt/lukzyPlace/
trooper_ish@redripper:~/notes$ sudo mount -o uid=1000,rw /dev/mapper/lukszy /mnt/lukzyPlace/
trooper_ish@redripper:~/notes$ echo testymctest >> /mnt/lukzyPlace/tesfile1
that worked, so then with encrypted partition still mounted the same, I tested as another user…
troop@redripper:/mnt$ echo exampletest >> /mnt/lukzyPlace/tesfile2
bash: /mnt/lukzyPlace/tesfile2: Permission denied
Okay, so seems the mounting permissions were blocking me…
trooper_ish@redripper:~/notes$ sudo umount /mnt/lukzyPlace/
trooper_ish@redripper:~/notes$ sudo mount -o uid=1000,gid=1001,rw /dev/mapper/lukszy /mnt/lukzyPlace/
trooper_ish@redripper:~/notes$ sudo mount -o uid=1000,gid=1001,umask=0007,rw /dev/mapper/lukszy /mnt/lukzyPlace/
(with group id from other normal, non admin user)
troop@redripper:/mnt$ echo exampletest >> /mnt/lukzyPlace/tesfile2
trooper_ish@redripper:~/notes$ cat /mnt/lukzyPlace/tesfile2
exampletest
Okay, that worked, on the system I set the partition up on. I ejected the drive, went to another computer, connected the usb drive, and gnome presented an option to mount the encrypted device.
I provided one of the keys, and it immediately connected the device, mounted it, and allowed my default user to read/write to it.
root@bakdeb:~# lsblk
└─sde5 8:69 0 100G 0 part
└─luks-ead45ad8-1ba7-4170-9005-44211dca547a
254:5 0 100G 0 crypt /media/othercomputeruser/EB73-FCE3
Pretty nifty… but not what I was testing.
root@bakdeb:~# umount /media/othercomputeruser/EB73-FCE3
root@bakdeb:~# cryptsetup close /dev/mapper/luks-ead45ad8-1ba7-4170-9005-44211dca547a
added a couple fresh users, and set passphrases, so would be clean with no old permissions etc…
root@bakdeb:~# adduser rod
root@bakdeb:~# adduser todd
reopened the luks container, and set the holding point for it as lukszy
root@bakdeb:~# cryptsetup open /dev/sde5 luckzy
which ulocks the container and sets it’s access point to the /dev/mapper location I specified, luckzy
then tested with new group id for user just created…
root@bakdeb:~# mkdir /mnt/lukszyTodd
root@bakdeb:~# grep todd /etc/passwd
todd:x:1002:1002:,,,:/home/todd:/bin/bash
root@bakdeb:~# mount -o gid=1002,umask=0007,rw /dev/mapper/lukszy /mnt/lukszyTodd/
root@bakdeb:~# su todd
todd@bakdeb:/root$
todd@bakdeb:/root$ echo thirdtest >> /mnt/lukszyTodd/tesfile3
todd@bakdeb:/root$ cat /mnt/lukszyTodd/tesfile3
thirdtest
todd@bakdeb:/root$ cat /mnt/lukszyTodd/tesfile1
testymctest
worked for writing and reading
TLDR: user or / and group permissions on mount is all I needed for it to work…