Menu

#38 crypt_activate_by_passphrase: Operation not permitted

pam-mount
closed-duplicate
pam-mount (40)
5
2014-09-12
2010-05-30
Mike
No

hi,

i want to mount a disk after login, as you see in the conf I at first mount my $home and then i want mount the other devices (/dev/sdb2) just with key files.
This is the way I created the key.

dd if=/dev/urandom of=movies bs=4k count=1
cryptsetup luksAddKey /dev/sdb2 movies
cryptsetup luksOpen /dev/sdb2 movies --key-file movies

this is the error I get.

m_mount(mount.c:196): Mount info: globalconf, user=mdomann <volume fstype="crypt_LUKS" server="(null)" path="/dev/sdb2" mountpoint="/home/mdomann/media" cipher="(null)" fskeypath="/home/mdomann/.gnupg/movies" fskeycipher="none" fskeyhash="none" options="" /> fstab=0
command: 'mount' '-p0' '-t' 'crypt_LUKS' '/dev/sdb2' '/home/mdomann/media'
pam_mount(misc.c:38): set_myuid<pre>: (uid=0, euid=0, gid=0, egid=0)
pam_mount(misc.c:38): set_myuid<post>: (uid=0, euid=0, gid=0, egid=0)
pam_mount(mount.c:64): Errors from underlying mount program:
pam_mount(mount.c:68): crypt_activate_by_passphrase: Operation not permitted

and this is the complete conf file.

mdomann@sysiphus:~$ cat /etc/security/pam_mount.conf.xml
<?xml version="1.0" encoding="utf-8" ?>
<pam_mount>
<volume user="mdomann" fstype="crypto_LUKS" path="/dev/sda3" mountpoint="/home" />
<luserconf name=".pam_mount.conf.xml"/>
<!--volume user="mdomann" path="/dev/sdb1" mountpoint="/home/mdomann/" fstype="crypt_LUKS" fskeyhash="none" fskeycipher="none" fskeypath="/home/mdomann/.gnupg/backup" /-->

<volume user="mdomann" path="/dev/sdb2" mountpoint="/home/mdomann/media" fstype="crypt_LUKS" fskeyhash="none" fskeycipher="none" fskeypath="/home/mdomann/.gnupg/movies" />

<debug enable="1" />

<!--
Create mountpoint if it does not exist yet. This is a good thing.

If enabled, and a mountpoint was created by pam_mount, the mountpoint will
be removed again on logout. To disable this behavior, use remove="false".
-->
<mkmountpoint enable="1" remove="true" />

<mntoptions allow="*" />
<!--
<mntoptions allow="noroot,nosuid,nodev,loop,encryption,fsck,nonempty,allow_root,allow_other" />
-->
<!--
<mntoptions deny="suid,dev" />
<mntoptions allow="*" />
<mntoptions deny="*" />
-->

<mntoptions require="nosuid,nodev" />

<!--
Commands to mount/unmount volumes. They can take parameters, as shown.

If you change the -p0 argument for lclmount, you'll need to modify the
source in mount.c (it sends the password to the stdin file descriptor of
the child process - look for STDIN_FILENO).

You can specify either absolute paths, or relative ones, in which case
$PATH will be searched. Since some login programs really behave
antisocial, pam_mount will always set its own $PATH.
-->

<path>/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin</path>

<lsof>lsof %(MNTPT)</lsof>

<fsck>fsck -p %(FSCKTARGET)</fsck>

<losetup>losetup -p0 "%(before=\"-e\" CIPHER)"
"%(ifnempty=\"-k\" KEYBITS)" %(KEYBITS) %(FSCKLOOP) %(VOLUME)</losetup>

<unlosetup>losetup -d %(FSCKLOOP)</unlosetup>

<cifsmount>mount -t cifs //%(SERVER)/%(VOLUME) %(MNTPT) -o
"user=%(USER),uid=%(USERUID),gid=%(USERGID)%(before=\",\" OPTIONS)"</cifsmount>

<davmount>mount -t davfs %(SERVER)/%(VOLUME) %(MNTPT) -o
"username=%(USER),uid=%(USERUID),gid=%(USERGID)%(before=\",\"
OPTIONS)"</davmount>

<smbmount>smbmount //%(SERVER)/%(VOLUME) %(MNTPT) -o
"username=%(USER),uid=%(USERUID),gid=%(USERGID)%(before=\",\" OPTIONS)"</smbmount>

<smbumount>smbumount %(MNTPT)</smbumount>

<ncpmount>ncpmount %(SERVER)/%(USER) %(MNTPT) -o
"pass-fd=0,volume=%(VOLUME)%(before=\",\" OPTIONS)"</ncpmount>

<ncpumount>ncpumount %(MNTPT)</ncpumount>

<fusemount>mount.fuse %(VOLUME) %(MNTPT)
"%(ifnempty=\"-o\" OPTIONS)" %(OPTIONS)</fusemount>

<fuseumount>fusermount -u %(MNTPT)</fuseumount>

<truecryptmount>truecrypt %(VOLUME) %(MNTPT)</truecryptmount>

<truecryptumount>truecrypt -d %(MNTPT)</truecryptumount>

<fd0ssh>pmt-fd0ssh</fd0ssh>

<!-- Linux supports lazy unmounting (-l). May be dangerous for encrypted
volumes. May also break loopback mounts because loopback devices are not
freed. Need to unmount mount point (not volume!) to support SMB mounts,
etc. -->
<umount>umount %(MNTPT)</umount>

<!-- On OpenBSD try "/usr/local/bin/mount_ehd" (included in pam_mount
package). -->
<lclmount>mount -p0 -t %(FSTYPE) %(VOLUME) %(MNTPT)
"%(ifnempty=\"-o\" OPTIONS)" %(OPTIONS)</lclmount>

<cryptmount>mount -t crypt "%(ifnempty=\"-o\" OPTIONS)" %(OPTIONS)
%(VOLUME) %(MNTPT)</cryptmount>

<nfsmount>mount %(SERVER):%(VOLUME) %(MNTPT)
"%(ifnempty=\"-o\" OPTIONS)" %(OPTIONS)</nfsmount>

<!-- mntcheck utility for BSDs which lack /etc/mtab -->
<mntcheck>mount</mntcheck>

<pmvarrun>pmvarrun -u %(USER) -o %(OPERATION)</pmvarrun>

<!--
Volumes that will be mounted when user triggers the pam_mount module
(usually at login).

<volume
user="*" | pgrp="foo" | sgrp="bar"
invert="1"
fstype="auto"
server="..."
path="..."
mountpoint="..."
ssh="1"
options="..."
fskeycipher="..."
fskeypath="..."
/>

USER is a user for which a volume rule applies, "*" selects all users
except root or any other user with UID 0.

A volume with PGRP attribute will be mounted when a user has that
particular group as its primary group. A volume with SGRP attribute will
be mounted when the user has the group as either primary or secondary.

USER, PGRP and SGRP are mutually exclusive. If neither is present,
USER="*" is assumed.

INVERT will invert the sense of the USER, PGRP or SGRP selector, thereby
making it possible to specify, e.g. "all users not in group xyz".

FSTYPE can be any filesystem type. If /bin/mount or the kernel does not
support it, you will get an error. You can use the special keyword "auto"
which automatically lets the kernel choose a matching filesystem. Note
that the kernel's auto feature only works with currently loaded
filesystems (listed in /proc/filesystem), so you will have to load the
necessary modules _first_ for them to be recognized with "auto". If this
attribute is not present, "auto" is assumed.

The "cifs", "davfs", "smbfs", "ncpfs", "fuse" and "truecrypt" types
override the identically-named kernel filesystems and use the
helper programs as defined above.

SERVER defines the server from which to source. The exact volume path
depends on the filesystem type. SMB uses //SERVER/VOLUME, NFS uses
SERVER:VOLUME. davfs uses SERVER/VOLUME. The attribute may be absent.

PATH specifies the location of the volume, locally or on the server (if
applies), respectively. This attribute is mandatory.

MOUNTPOINT specifies the destination directory onto which the volume is
mounted. '~' expands to the user's home directory as present in the passwd
database, according to sh semantics. "~name" is not supported. If this
attribute is omitted, the location is read from /etc/fstab, which also
requires PATH to be the device of an fstab entry.

The SSH option enables an input hack wrapper (zerossh) for this mount
to hand the password to ssh over an ssh-specific mechanism. Enable this
option for any mount involving the SSH binary, e.g. ccgfs or sshfs. Do
NOT enable it for anything else or the login will most likely hang.

OPTIONS specifies mount options. If omitted, and /etc/fstab is used (see
MOUNTPOINT), then the options are also sourced from fstab.

Note that if the mount command has specified an option, e.g. %(KEYBITS)
and you do not specify a value, a warning is printed in the log. The
warning can usually be ignored, except when the option is mandatory.

SMB mounts require the `smbmount` and `smbumount` programs, NCP `ncpmount`
and `ncpumount`. Both SMB and NCP work in ~/.pam_mount.conf.xml.

General examples:

<volume user="user" fstype="smbfs" server="krueger" path="public"
mountpoint="/home/user/krueger" />

<volume user="user" fstype="ncpfs" server="krueger" path="public"
mountpoint="/home/user/krueger" options="user=user.context" />

<volume fstype="smbfs" server="krueger" path="homes"
mountpoint="/home/%(USER)/remote" options="dmask=0711" />

<volume fstype="davfs" server="https://dev.computergmbh.de/"
path="/svn/libHX/trunk" mountpoint="/projects/libHX" />

You can use ~ to use whatever home directory the user has (therefore you
can distribute home directories along more than one location. This is
useful for pam_chroot:

<volume path="/bin" mountpoint="~/bin" options="bind" />

For FUSE mounts, use something like this:

<volume fstype="fuse" path="sshfs#%(USER)@fileserver:"
mountpoint="~" />

<volume fstype="nfs" server="fileserver" path="/home/%(USER)"
mountpoint="~" />

Some more examples:

<volume path="/home/%(USER).img" mountpoint="~" fskeycipher="aes-256-ecb"
fskeypath="/etc/ehd/%(USER)" />

Windows 2000, which requires a domain specified (does it really? works for
me without -jengelh), example (thanks John Knox):

<volume fstype="smbfs" server="viper" path="%(USER)"
mountpoint="~" options="dmask=0751,workgroup=WINDOWS_DOMAIN" />

-->

<!--
Linux encrypted home directory examples, using dm_crypt:

crypt mounts require a kernel with CONFIG_BLK_DEV_DM and CONFIG_DM_CRYPT
enabled as well as all the used ciphers (e.g. CONFIG_CRYPTO_AES_586,
CONFIG_CRYPTO_TWOFISH, etc.). crypt mounts must be in the global config
file /etc/security/pam_mount.conf.xml.

Linux encrypted home directory examples, using dm_crypt:

<volume fstype="crypt" path="/dev/sda2" mountpoint="/home/user"
options="cipher=aes" fskeycipher="aes-256-ecb"
fskeypath="/home/user.key" />

cryptoloop mounts require a kernel with CONFIG_BLK_DEV_CRYPTOLOOP enabled.
cryptoloop mounts must be in the global config
/etc/security/pam_mount.conf.xml. Linux encrypted home directory examples,
using cryptoloop:

<volume path="/dev/hda3" mountpoint="/home/"
options="loop,encryption=aes" />

<volume path="/home/user.img" mountpoint="/home/user"
options="loop,user,exec,encryption=aes,keybits=256" />

<volume path="/home/user.img" />

<volume path="/home/user.img" fskeycipher="aes-256-ecb"
fskeypath="/home/user4.key" />

The last two examples (^^) need a line like the following in /etc/fstab:

/home/user4.img /home/user4 xfs user,loop,encryption=aes,keybits=256,noauto 0 0

OpenBSD encrypted home directory example (see also lclmount above):

<volume path="/home/user.img" mountpoint="/home/user"
options="svnd0" />

Volatile tmpfs mount with restricted size (thanks to Mike Hommey for this
example):

<volume user="test" fstype="tmpfs" path="none" mountpoint="/home/test"
options="size=10M,uid=test,gid=users,mode=0700" />

See http://www.tldp.org/HOWTO/Loopback-Encrypted-Filesystem-HOWTO.html to
learn how to create a encrypted loopback filesystem.

If the volume's password is different than the user's login password, the
following technique may be used (see also README):

{...} are placeholders, insert the proper value there!

1. Create a file containing the volume's password (FS key). If you are
using pam_mount to mount an loopback encrypted volume, this password
should be generated with /dev/urandom.

Simple example:
echo {volume password} | openssl enc -aes-256-ecb >/home/user.key
Encrypt this file using the user's login password as the key.

Verbose loopback encrypted volume example:
a. dd if=/dev/urandom of=/home/user.img bs=1M count={image size in MB}
b. dd if=/dev/urandom bs=1c count={keysize/8} | \
openssl enc -{fs key cipher} >/home/user.key
Encrypt this file using the user's login password as the key.
c. modprobe -q cryptoloop
d. openssl enc -d -{fs key cipher} -in /home/user.key | \
losetup -e aes -k {keysize} -p0 /dev/loop0 /home/user.img
e. mkfs -t ext2 /dev/loop0
f. losetup -d /dev/loop0

3. In pam_mount.conf.xml:
a. Set the fs key cipher variable to the cipher used
(ie: aes-256-ecb).
b. Set the fs key path variable to the key's path
(ie: /home/user.key)

4. If a user changes his login password, regenerate the efsk that was
created in step 1b. A script named passwdehd is provided to do this.

If FSKEYCIPHER is empty, then the user's login password is also the
volume's password.
-->

<!--
When pam_mount is not used with "use_first_pass" or "try_first_pass" in
the PAM configuration files (/etc/pam.d/), it will have to ask for a
password. This is also the case if pam_mount is the first auth module
in the block.
-->
<msg-authpw>pam_mount password:</msg-authpw>

<!--
In case the 'session' PAM block does not have the password (e.g. on su
from root to user), it will ask again.
-->
<msg-sessionpw>reenter password for pam_mount:</msg-sessionpw>

</pam_mount>

any suggestion for me?

thanks

Discussion

  • Jan Engelhardt

    Jan Engelhardt - 2010-06-22
    • labels: --> pam-mount
    • milestone: --> pam-mount
    • assigned_to: nobody --> jengelh
    • status: open --> pending-duplicate
     
  • Jan Engelhardt

    Jan Engelhardt - 2010-06-22

    Make sure you use at least pam_mount 2.3 and strip your config file (cf. shipped file).

     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
  • SourceForge Robot

    • status: pending-duplicate --> closed-duplicate
     

Log in to post a comment.

MongoDB Logo MongoDB