Problem mit pam_mount und sshfs

Problem mit pam_mount und sshfs

Ich versuche, die automatische Bereitstellung der Home-Verzeichnisse der Benutzer mithilfe pam_mountvon SSHFS zu konfigurieren (Benutzer sind LDAP-Benutzer auf dem Remotecomputer).

Ich habe Folgendes konfiguriert pam_mount:

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE pam_mount SYSTEM "pam_mount.conf.xml.dtd">
<pam_mount>
<debug enable="1" />
<mntoptions allow="nosuid,nodev,loop,encryption,fsck,nonempty,allow_root,allow_other" />
<mntoptions require="nosuid,nodev" />
<logout wait="0" hup="0" term="0" kill="0" />
<mkmountpoint enable="1" remove="true" />
<volume fstype="fuse" path="sshfs#%(USER)@HOSTNAME:" mountpoint="~" ssh="1" options="reconnect,idmap=user,password_stdin,nonempty" />
</pam_mount>

Wenn ich versuche, sumich anzumelden, werde ich nach dem Passwort gefragt:

root@debian:~# su - pszubert
pam_mount(pam_mount.c:553): pam_mount 2.5: entering session stage
reenter password for pam_mount:
pam_mount(misc.c:38): Session open: (ruid/rgid=0/20001, e=0/20001)
pam_mount(mount.c:213): Mount info: globalconf, user=pszubert <volume fstype="fuse" server="(null)" path="sshfs#pszubert@HOST:" mountpoint="/home/pszubert" cipher="(null)" fskeypath="(null)" fskeycipher="(null)" fskeyhash="(null)" options="reconnect,idmap=user,password_stdin,nonempty" /> fstab=0 ssh=1
command: 'pmt-fd0ssh' 'mount.fuse' 'sshfs#pszubert@HOST:' '/home/pszubert' '-oreconnect,idmap=user,password_stdin,nonempty' 
pam_mount(spawn.c:108): setting uid to user pszubert
pam_mount(misc.c:38): set_myuid<post>: (ruid/rgid=20001/20001, e=20001/20001)
System plików  Typ bl.  1K B        użyte dostępne %uż. zamont. na
/dev/sda1     ext3     7867856    940236   6527956  13% /
tmpfs        tmpfs      192316         0    192316   0% /lib/init/rw
proc          proc           0         0         0   -  /proc
sysfs        sysfs           0         0         0   -  /sys
udev         tmpfs      187872       148    187724   1% /dev
tmpfs        tmpfs      192316         0    192316   0% /dev/shm
devpts      devpts           0         0         0   -  /dev/pts
fusectl    fusectl           0         0         0   -  /sys/fs/fuse/connections
pam_mount(pam_mount.c:521): mount of sshfs#pszubert@HOST: failed
command: 'pmvarrun' '-u' 'pszubert' '-o' '1' 
pam_mount(misc.c:38): set_myuid<pre>: (ruid/rgid=0/20001, e=0/20001)
pam_mount(misc.c:38): set_myuid<post>: (ruid/rgid=0/20001, e=0/20001)
pmvarrun(pmvarrun.c:248): parsed count value 0
pam_mount(pam_mount.c:440): pmvarrun says login count is 1
pam_mount(pam_mount.c:643): done opening session (ret=0)

Im HOST auth.loggibt es Informationen:

Mar 17 22:13:42 student sshd[17889]: Accepted password for pszubert from 85.202.159.212 port 20264 ssh2
Mar 17 22:13:42 student sshd[17889]: pam_unix(sshd:session): session opened for user pszubert by (uid=0)
Mar 17 22:13:42 student sshd[17891]: subsystem request for sftp
Mar 17 22:13:42 student sshd[17891]: Received disconnect from XXXXXXXXXX: 11: disconnected by user
Mar 17 22:13:42 student sshd[17889]: pam_unix(sshd:session): session closed for user pszubert

Was seltsam ist: Wenn ich angemeldet bin, kann ich Remote-FS mithilfe von mounten sshfs pszubert@HOST: a/.

Was ist falsch?

Ich denke, das Problem liegt ~/.ssham lokalen Rechner. Das erste Problem betraf known_hostsdie Datei, also habe ich eine globale known_hostsDatei erstellt /etc/ssh/ssh_known_hosts. Jetzt ~/.sshwird sie immer noch erstellt, ist aber leer, selbst wenn ich mich manuell mit dem Remote-Host verbinde. Ich denke, wenn ich die Erstellung verhindern könnte, ~/.sshwäre das Problem gelöst. Gibt es eine Möglichkeit, sie zu deaktivieren?

Antwort1

Ich habe das Problem gelöst.

Zuerst habe ich eine globale known_hostsDatei in erstellt /etc/ssh/ssh_known_hosts.

Das Hauptproblem war in dieser Debugzeile sichtbar:

command: 'pmt-fd0ssh' 'mount.fuse' 'sshfs#pszubert@HOST:' '/home/pszubert' '-oreconnect,idmap=user,password_stdin,nonempty'

Wie wir sehen können, gibt es zwischen -oden Optionen kein Leerzeichen.

Zeile hinzufügen:

<fusemount>mount.fuse %(VOLUME) %(MNTPT) -o %(OPTIONS)</fusemount>

zur pam_mountKonfigurationsdatei ( /etc/security/pam_mount.conf.xml) Problem gelöst. Jetzt mount.fuseheißt es auf diese Weise:

command: 'pmt-fd0ssh' 'mount.fuse' 'sshfs#pszubert@HOST:' '/home/pszubert' '-o' 'reconnect,nonempty'

Die nächsten wichtigen Dinge sind die Berechtigungen für /dev/fuseund /usr/bin/fusermount. Der Benutzer sollte in der Gruppe sein fuse. In meinem Fall war das nicht möglich, da es sich um einen Remote-Benutzer handelte, also habe ich die Berechtigungen manuell geändert:

chmod o+x /usr/bin/fusermount
chmod o+rw /dev/fuse

verwandte Informationen