sshd
$ /usr/sbin/sshd -f testconfig -p 22025 -d
debug1: sshd version OpenSSH_5.2p1
debug1: private host key: #0 type 0 RSA1
debug1: read PEM private key done: type RSA
debug1: private host key: #1 type 1 RSA
debug1: read PEM private key done: type DSA
debug1: private host key: #2 type 2 DSA
debug1: setgroups() failed: Operation not permitted
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-f'
debug1: rexec_argv[2]='testconfig'
debug1: rexec_argv[3]='-p'
debug1: rexec_argv[4]='22025'
debug1: rexec_argv[5]='-d'
debug1: Bind to port 22025 on 127.0.0.1.
Server listening on 127.0.0.1 port 22025.
Generating 1024 bit RSA key.
RSA key generation complete.
debug1: fd 4 clearing O_NONBLOCK
debug1: Server will not fork when running in debugging mode.
debug1: rexec start in 4 out 4 newsock 4 pipe -1 sock 7
debug1: inetd sockets after dupping: 3, 3
Connection from 127.0.0.1 port 58477
debug1: Client protocol version 2.0; client software version OpenSSH_5.5
debug1: match: OpenSSH_5.5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.2
debug1: privsep_preauth: successfully loaded Seatbelt profile for unprivileged child
debug1: list_hostkey_types:
No supported key exchange algorithms
debug1: do_cleanup
debug1: do_cleanup
debug1: audit_event: unhandled event 12
远程控制
$ ssh [email protected] -p 22025 -i ./id_rsa.pub -v
OpenSSH_5.5p1, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /Users/dgl/.ssh/config
debug1: Reading configuration data /opt/local/etc/ssh/ssh_config
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 22025.
debug1: Connection established.
debug1: identity file ./id_rsa.pub type 1
debug1: identity file ./id_rsa.pub-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.2
debug1: match: OpenSSH_5.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.5
debug1: SSH2_MSG_KEXINIT sent
Connection closed by 127.0.0.1
ssh_配置
Protocol 1,2
ListenAddress 127.0.0.1
HostKey ./ssh_host_key
HostKey ./ssh_host_rsa_key
HostKey ./ssh_host_dsa_key
RSAAuthentication yes
PubkeyAuthentication yes
答案1
我刚刚遇到了同样的问题,通过将我的相对 HostKey 路径变成绝对路径来解决它,即
HostKey ./ssh_host_key
放:
HostKey /home/dmitry/ssh_host_key
或无论它在哪儿。
那个错误没什么帮助,是吗?
答案2
我在 Fedora 上遇到了这个问题。最终我注意到:
root@wisdom:/etc/ssh# ll
total 268K
drwxr-xr-x. 2 root root 4.0K Jun 30 06:06 ./
drwxr-xr-x. 128 root root 12K Jun 30 05:15 ../
-rw-r--r--. 1 root root 237K Jun 8 23:30 moduli
-rw-r--r--. 1 root root 2.2K Jun 8 23:30 ssh_config
-rw-------. 1 root root 4.3K Jun 30 06:03 sshd_config
-rw-r-----. 1 root ssh_keys 0 Jun 27 00:46 ssh_host_ecdsa_key
-rw-r--r--. 1 root root 0 Jun 27 00:46 ssh_host_ecdsa_key.pub
-rw-r-----. 1 root ssh_keys 0 Jun 27 00:46 ssh_host_ed25519_key
-rw-r--r--. 1 root root 0 Jun 27 00:46 ssh_host_ed25519_key.pub
-rw-r-----. 1 root ssh_keys 0 Jun 27 00:46 ssh_host_rsa_key
-rw-r--r--. 1 root root 0 Jun 27 00:46 ssh_host_rsa_key.pub
密钥文件的长度为零!我生成了新的密钥对,并解决了该问题:
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key
答案3
顺便说一句,我刚刚遇到了同样的错误消息,但原因不同。就我而言,问题出在我的主机私钥文件的模式是 640 而不是 600。快速 chmod 和 sshd 重启解决了这个问题。我猜这里的共同主题是 sshd 由于某种原因没有加载主机密钥。
答案4
我确实遇到了这个问题......它是我们的老朋友 SELinux。
运行setenforce 0
证明它有效,但这不是一个好的解决方案。然而,这有助于让最终的解决方案更加清晰。
$ cd /etc/ssh
$ restorecon -Rv *
重新启用 SELinux(setenforce 1
)...一切正常。