pam_mount 和 sshfs 的问题

pam_mount 和 sshfs 的问题

我正在尝试使用pam_mountsshfs 配置用户主目录的自动挂载(用户是远程计算机上的 LDAP 用户)。

我配置了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>

当我尝试su使用用户时,系统会询问我密码:

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)

在HOST中auth.log有信息:

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

奇怪的是,当我登录时,我可以使用挂载远程文件系统sshfs pszubert@HOST: a/

怎么了?

我认为问题出~/.ssh在本地机器上。第一个问题是关于known_hosts文件的,所以我known_hosts/etc/ssh/ssh_known_hosts.现在~/.ssh仍然创建,但即使我手动连接到远程主机也是空的。我认为如果我能阻止创造~/.ssh它就能解决问题。有办法禁用它吗?

答案1

我解决了问题。

首先我known_hosts/etc/ssh/ssh_known_hosts.

主要问题在这行调试中可见:

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

-o正如我们所看到的, 和 选项之间没有空格。

添加行:

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

配置pam_mount文件(/etc/security/pam_mount.conf.xml)解决了问题。现在mount.fuse这样称呼:

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

接下来重要的事情是/dev/fuse和 的权限/usr/bin/fusermount。用户应该在fuse组中。就我而言,这是不可能的,因为它是远程用户,所以我手动更改了权限:

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

相关内容