我试图让MySQL作为后端在CentOS 6.3上对用户进行身份validation。 到目前为止,我已经成功安装并configuration了libnss-mysql。 我可以通过做这个testing:
# groups testuser testuser : sftp
Testuser是sftp组的成员,事实上,所有基于MySQL的useraccounts都将被硬编码到它。 sftp组被chrooted,并被迫使用internal-sftp,所以他们不能做任何事情,只能访问他们的主目录。
然后我configuration了pam-mysql和PAM以允许mysqllogin。 这也适用于.. 当SELinux不执行。
当我setenforce 1用户不能再login。 错误:
权限被拒绝,请重试。
这是我的pam_mysql.conf文件:
users.host=localhost users.db_user=nss-pam-user users.db_passwd=*********** users.database=sftpusers users.table=users users.user_column=username users.password_column=password users.password_crypt=6 verbose=1
我的/etc/pam.d/sshd :
#%PAM-1.0 auth sufficient pam_sepermit.so auth include password-auth auth required pam_mysql.so config_file=/etc/pam_mysql.conf account sufficient pam_nologin.so account include password-auth account required pam_mysql.so config_file=/etc/pam_mysql.conf 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 optional pam_keyinit.so force revoke session include password-auth
并要完成一些日志文件的内容..
/var/logs/secure Nov 20 14:52:20 hostname unix_chkpwd[4891]: check pass; user unknown Nov 20 14:52:20 hostname unix_chkpwd[4891]: password check failed for user (testuser) Nov 20 14:52:20 hostname sshd[4880]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.10.107 user=testuser Nov 20 14:52:22 sftpusers sshd[4880]: Failed password for testuser from 192.168.10.107 port 51849 ssh2 /var/logs/audit/audit.log type=USER_AUTH msg=audit(1353420107.070:812): user pid=5285 uid=0 auid=500 ses=24 subj=unconfined_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=pubkey acct="testuser" exe="/usr/sbin/sshd" hostname=? addr=192.168.10.107 terminal=ssh res=failed' type=USER_AUTH msg=audit(1353420112.312:813): user pid=5285 uid=0 auid=500 ses=24 subj=unconfined_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=PAM:authentication acct="testuser" exe="/usr/sbin/sshd" hostname=192.168.10.107 addr=192.168.10.107 terminal=ssh res=failed' type=USER_AUTH msg=audit(1353420112.456:814): user pid=5285 uid=0 auid=500 ses=24 subj=unconfined_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=password acct="testuser" exe="/usr/sbin/sshd" hostname=? addr=192.168.10.107 terminal=ssh res=failed'
我试图让audit2why为什么解释这个问题,但即使有一些错误,它仍然保持沉默。
有没有人看到这个问题? 谢谢!
编辑:原来它几乎与setenforce 0工作setenforce 0我可以mkdir foobar但如果我做一个ls我得到一个错误: Received message too long 16777216
CentOS 6.3随OpenSSH5.3p1一起提供,有一个已知的错误,它会阻止sftp检索文件的组名,结果是抛出一个错误,并且只要给出ls命令就closures连接。
解决scheme是下载一个更新版本的OpenSSH,我花了6.1p1,并从源代码构build。
大多数情况下,我遵循这些指示: http : //kb.bobcares.com/? View=entry&EntryID= 1059 ,在我的情况下libwrap是缺less它必须安装。 我做了:
yum install tcp_wrappers-devel
其他一些库可能会丢失,安装完成后,我configurationOpenSSH来启用SELinux,当你达到这一步:
./configure --prefix=/usr/local/ssh --with-md5-passwords --with-pam --with-tcp-wrappers --with-kerberos5 --with-ssl-engine
做这个,而不是:
./configure --prefix=/usr/local/ssh --with-selinux --with-md5-passwords --with-pam --with-tcp-wrappers --with-kerberos5 --with-ssl-engine
您的默认sshd_config文件将更改为前缀位置的:
/usr/local/ssh/etc/sshd_config
通过该文件复制我现有的configuration(你也可以别名)我的configuration奇迹般地开始工作!