“连接由[HOST IP]关闭”使用DSA密钥认证(“Connection closed by [H

2019-07-28 21:18发布

我一直在使用Perceus Cluster软件(共享/家庭设置http://perceus.org )对于我们的集群。 节点使用的CentOS 6.1 x86_64的。 /家从头部到节点通过NFS(NFSv4的)共享。

root@head~]$ 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] user@head
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中允许基于密钥认证(Pubkey验证是)。 我已经确定的/ home的权限(一旦被安装在节点上)是正确的。 用户正确验证。 我曾尝试NFS有和没有“no_all_squash”重启NFS,rpcidmap,RPCBIND和nfslock安装。

我曾与centos5这样做的工作安装了不同的主/头节点的节点上。 CentOS6只是似乎是给我这个额外的问题。

如果我没有创建的关键,当然我提示输入密码。

我的hosts.allow /拒绝都在客户端和服务器空。

root用户能够连接。 Perceus处理用于根用户,因为它是虚拟文件系统的一部分密钥生成。 我猜,什么是错我的密钥的生成,但我想不出是什么问题。

Answer 1:

正确的解决方案是解决问题,而不是禁用PAM使用情况,您可能隐藏安全问题。

SSH是失败,因为PAM是失败的一些检查拒绝用户登录。 验证/etc/pam.d/sshd什么规则,你有什么可能会失败。

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

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

PermitEmptyPasswords no

这将阻止SSH允许没有密码的用户登录(但不执行任何其他协议,如TELNET,FTP,HTTP和登录)。



Answer 2:

解:

继以下的建议我检查/var/log/security节点(主机)上。 这显示了:

fatal: Access denied for user user by PAM account configuration

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

UsePAM yes

UsePAM no

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

谢谢!



Answer 3:

这是不好的使用密码的授权。 被打开了SELinux这些服务器上? 如果是的话,你或者关闭SELinux的,或通过“的restorecon -R -v / home / user中恢复默认SELinux策略/。 这是一个已知的问题



Answer 4:

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

事实证明我的问题,可能你的,是造成的,因为我的家目录是NFS挂载和selinux (在CentOS 7)被扔了一些错误(这是非常难以追查)。 此修复程序很简单,虽然。

setsebool -P use_nfs_home_dirs 1


Answer 5:

就我而言,我还没有使用useradd的未创建的用户,相反,我已经添加在/ etc / passwd文件中的用户和创建的主目录与所有所需文件的用户。

使用useradd命令创建用户并添加创建的.ssh在用户的主目录的目录后,酒馆关键authorized_keys文件后,这个问题得到了解决。

顺便说一句,我使用CentOS的7

希望这有助于一些之一。



Answer 6:

对于我来说,我有腐败pam.d文件。 我在一组新的复制从类似的服务器和所有再次充分。 我没有花时间去寻找具体的腐败,但认为我想补充我的2位的情况下,任何人在将来读这一点,需要一些更多的想法。



文章来源: “Connection closed by [HOST IP]” using dsa key authentication
标签: ssh openssh