2012-04-10 22 views
9

对于我们的群集,我使用Perceus群集软件(http://perceus.org)进行共享/主目录设置。节点正在使用CentOS 6.1 x86_64。 /home通过nfs(NFSv4)从头到节点共享。“通过[HOST IP]关闭的连接”使用dsa密钥身份验证

[email protected]~]$ cat /etc/exports 
/var/lib/perceus/ 10.10.10.0/255.255.255.0(ro,no_root_squash,async) 
/home/ 10.10.10.0/255.255.255.0(rw,no_root_squash,no_all_squash,async) 

这里是每个节点上的/ etc/fstab(全部相同)。

... 
10.10.10.2:/var/lib/perceus/ /var/lib/perceus/ nfs ro,soft,bg 0 0 
10.10.10.2:/home/ /home nfs rw,soft,bg 0 0 

节点上的/ etc/fstab是具有相同UID:GID的主/主副本。

我曾尝试使用下面的方法创建密钥对:

$ cd ~ 
$ rm -rf .ssh 
$ mkdir .ssh 
$ chmod 700 .ssh 
$ ssh-keygen -t dsa -P "" 
Generating public/private dsa key pair. 
Enter file in which to save the key (/home/user/.ssh/id_dsa): 
Your identification has been saved in /home/user/.ssh/id_dsa. 
Your public key has been saved in /home/user/.ssh/id_dsa.pub. 
The key fingerprint is: 
[SNIPPED] [email protected] 
The key's randomart image is: 
+--[ DSA 1024]----+ 
[SNIPPED] 
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys 
$ chmod 400 ~/.ssh/authorized_keys 

这是问题所在。当我尝试SSH入每个节点,我得到一个“连接关闭”错误。这是调试输出。

$ ssh node01 
Connection closed by 10.10.10.101 

$ ssh node01 -vvv 
OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: Applying options for * 
debug2: ssh_connect: needpriv 0 
debug1: Connecting to node01 [10.10.10.101] port 22. 
debug1: Connection established. 
debug1: identity file /home/user/.ssh/identity type -1 
debug1: identity file /home/user/.ssh/id_rsa type -1 
debug3: Not a RSA1 key file /home/user/.ssh/id_dsa. 
debug2: key_type_from_name: unknown key type '-----BEGIN' 
debug3: key_read: missing keytype 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug3: key_read: missing whitespace 
debug2: key_type_from_name: unknown key type '-----END' 
debug3: key_read: missing keytype 
debug1: identity file /home/user/.ssh/id_dsa type 2 
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3 
debug1: match: OpenSSH_5.3 pat OpenSSH* 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_5.3 
.... SNIPPED ... 
debug2: dh_gen_key: priv key bits set: 139/256 
debug2: bits set: 482/1024 
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY 
debug3: Wrote 144 bytes for a total of 981 
debug3: check_host_in_hostfile: filename /home/user/.ssh/known_hosts 
debug3: check_host_in_hostfile: match line 1 
debug3: check_host_in_hostfile: filename /home/user/.ssh/known_hosts 
debug3: check_host_in_hostfile: match line 1 
debug1: Host 'node01' is known and matches the RSA host key. 
debug1: Found key in /home/user/.ssh/known_hosts:1 
debug2: bits set: 501/1024 
debug1: ssh_rsa_verify: signature correct 
debug2: kex_derive_keys 
debug2: set_newkeys: mode 1 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug3: Wrote 16 bytes for a total of 997 
debug2: set_newkeys: mode 0 
debug1: SSH2_MSG_NEWKEYS received 
debug1: SSH2_MSG_SERVICE_REQUEST sent 
debug3: Wrote 48 bytes for a total of 1045 
debug2: service_accept: ssh-userauth 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug2: key: /home/user/.ssh/identity ((nil)) 
debug2: key: /home/user/.ssh/id_rsa ((nil)) 
debug2: key: /home/user/.ssh/id_dsa (0x7f79b940f650) 
debug3: Wrote 64 bytes for a total of 1109 
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password 
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password 
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password 
... [SNIPPED]... 
debug1: Next authentication method: publickey 
debug1: Trying private key: /home/user/.ssh/identity 
debug3: no such identity: /home/user/.ssh/identity 
debug1: Trying private key: /home/user/.ssh/id_rsa 
debug3: no such identity: /home/user/.ssh/id_rsa 
debug1: Offering public key: /home/user/.ssh/id_dsa 
debug3: send_pubkey_test 
debug2: we sent a publickey packet, wait for reply 
debug3: Wrote 528 bytes for a total of 1637 
debug1: Server accepts key: pkalg ssh-dss blen 434 
debug2: input_userauth_pk_ok: SHA1 fp 46:a2:c3:86........... 
debug3: sign_and_send_pubkey 
debug1: read PEM private key done: type DSA 
debug3: Wrote 592 bytes for a total of 2229 
Connection closed by 10.10.10.101 

我确定/ etc/ssh/sshd_config允许基于密钥的身份验证(PubkeyAuthentication yes)。 我已经确保/ home上的权限(一旦安装在节点上)是正确的。用户被正确认证。 我试过nfs挂载有和没有“no_all_squash”重新启动nfs,rpcidmap,rpcbind和nfslock。

我已经与CentOS5一起工作,安装在具有不同主/节点的节点上。 CentOS6似乎给我带来了额外的问题。

如果我不创建密钥,当然我会提示输入密码。

我的hosts.allow/deny在客户端和服务器上都是空的。

root用户能够连接。由于Perceus是虚拟文件系统的一部分,它为root用户处理密钥生成。我猜测我的钥匙生成有问题,但我无法弄清楚问题所在。

+0

看看'的/ var /日志/安全*'当您连接 – lunixbochs 2012-04-10 21:02:50

+0

发现: '致命的:拒绝访问用户用户通过PAM帐户configuration' – qtipp 2012-04-11 03:04:02

回答

4

SOLUTION:

按照下面我建议节点(主机)上选中/var/log/security。这表明:

fatal: Access denied for user user by PAM account configuration 

我然后编辑/etc/ssh/sshd_config变化:

UsePAM yes 

UsePAM no 

重新启动节点,我现在可以进行无密码登录。

谢谢!

13

正确的解决方案是解决问题,而不是禁用pam使用,因为您可能隐藏了安全问题。

ssh失败,因为PAM通过检查失败拒绝用户登录。 验证/etc/pam.d/sshd你有什么规则和什么可能失败。

最常见的问题是没有密码的用户(比较/etc/passwd/etc/shadow,或检查/etc/nsswitch/etc/pam.d/*,看看那里的用户,并权威性是来自),也没有主目录,缺少一些额外的身份验证的配置,UID过低或过高等

如果它丢失的密码,至少确保你这个在/etc/ssh/sshd_config

PermitEmptyPasswords no 

此块ssh来允许在没有密码的用户登录(但无助于其他协议,李ke telnet,f​​tp,http和登录)。

+1

谢天谢地,你的回答!我一直在想,为什么一个特定的用户(gpadmin)不能在本地主机上ssh,'.ssh'中的所有其他内容都被正确的权限设置正确 - 事实证明这是一个无密码的用户。我只是做了'sudo passwd gpadmin',现在用户可以像其他人一样在本地主机上ssh。 – 2013-02-24 01:54:25

+0

谢谢你的回答。我只是在/ etc/passwd中克隆了一个用户,但是不在/ etc/shadow中... – Mildred 2013-05-24 17:59:29

+1

gee,你让我的一天:密码无需密码登录...怎么可能? – 2013-07-08 15:21:53

1

使用无密码授权并不好。 selinux是否打开这些服务器?使用useradd的如果是的话,那么你或者关闭SELinux的,或通过“的restorecon -R -v /家庭/用户/恢复默认SELinux策略。 This is a known issue

0

就我而言,我的天堂不创建的用户,而不是我在/ etc/passwd文件中添加了用户,并为用户创建了所有必需文件的主目录。

在创建.ssh目录后,使用useradd创建用户并将pub键添加到authorized_keys文件用户的主目录,问题得到解决。

顺便说一句我用的是centos 7

希望这对一些人有帮助。

0

对我来说,我有损坏的pam.d文件。我从一个类似的服务器复制了一个新的集合,一切都很顺利。我没有花时间去寻找具体的腐败行为,但是我认为我会添加我的2位以防万一任何人在将来阅读此内容并需要更多的想法。

1

我有一个非常类似的问题,你的。

事实证明,我的问题,可能是你的,是因为我的主目录是一个NFS安装,并且selinux(在CentOS 7上)抛出了一些错误(很难追查)。虽然修复很简单。

setsebool -P use_nfs_home_dirs 1 
相关问题