我的 SFTP 服务需要特定的 PAM 配置,因此我复制了sshd
可执行文件并将其重命名sftpd
。
然后,我设置了一个特定的配置来/etc/pam.d/sftpd
根据 LDAP 对用户进行身份验证,而普通用户则照常进行身份验证。
一切都很好,但问题是,在 RedHat EL 7.4 上sftpd
配置并作为systemd
服务启动的“新”守护进程不会跟踪操作(opendir、chdir 等等)。
配置和常规的一样sshd
,特别是这一行:
Subsystem sftp internal-sftp -l VERBOSE
但什么也没发生auth.log
。
有没有好奇的sshd
如果守护进程以不同的名称运行,我应该注意的副作用是什么?
提前感谢你的帮助
答案1
事实证明,这与重命名无关。问题来自 pam_ldap 配置。我在文件中一行的末尾添加了 debug /etc/pam.d/sftpd
,如下所示:
#%PAM-1.0
auth required pam_ldap.so
auth required pam_sepermit.so
auth include postlogin
## Used with polkit to reauthorize users in remote sessions
-auth optional pam_reauthorize.so prepare
account required pam_ldap.so debug
account required pam_nologin.so
account include password-auth
password sufficient pam_ldap.so
password include password-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open env_params
session required pam_namespace.so
session optional pam_keyinit.so force revoke
session include password-auth
session include postlogin
# Used with polkit to reauthorize users in remote sessions
-session optional pam_reauthorize.so prepare
并且日志重新出现在 /var/log/secure 中:
Jun 13 15:11:38 somehost sftpd[40543]: session opened for local user USER01 from [xxx.xxx.28.32] [postauth]
Jun 13 15:11:38 somehost sftpd[40543]: received client version 3 [postauth]
Jun 13 15:11:38 somehost sftpd[40543]: realpath "." [postauth]
Jun 13 15:11:42 somehost sftpd[40543]: realpath "/chroot" [postauth]
Jun 13 15:11:42 somehost sftpd[40543]: opendir "/chroot" [postauth]
Jun 13 15:11:42 somehost sftpd[40543]: closedir "/chroot" [postauth]
Jun 13 15:11:42 somehost sftpd[40543]: realpath "/chroot/somedir" [postauth]
Jun 13 15:11:42 somehost sftpd[40543]: opendir "/chroot/somedir" [postauth]
Jun 13 15:11:43 somehost sftpd[40543]: closedir "/chroot/somedir" [postauth]