首先,我知道这个问题已经有一百万次了,我已经看了所有我能find的东西,而且还不能解决问题。
我遇到这个问题时,从我的Mac ssh'ing我的Ubuntu服务器上一个全新的Ubuntu安装(我重新安装,因为这个问题)。
我有SSH端口映射到7070,因为我的ISP阻止22。
在客户端:
bash: ssh -p 7070 -v [email protected] debug1: Reading configuration data /etc/ssh_config debug1: Connecting to address.org port 7070. debug1: Connection established. debug1: identity file /home/me/.ssh/identity type -1 debug1: identity file /home/me/.ssh/id_rsa type 1 debug1: identity file /home/me/.ssh/id_dsa type -1 ssh_exchange_identification: Connection closed by remote host
以下是我所做的尝试解决问题的方法:
确保我的maxstartups可以:
bash: grep MaxStartups /etc/ssh/sshd_config #MaxStartups 10:30:60
当我运行telnet localhost ,我得到这个:
telnet localhost Trying ::1... Trying 127.0.0.1... telnet: Unable to connect to remote host: Connection refused
当我运行/ usr / sbin / sshd -t
Could not load host key: /etc/ssh/ssh_host_rsa_key Could not load host key: /etc/ssh/ssh_host_dsa_key
当我重新生成密钥
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
我犯了同样的错误。
我很确定这是问题。 谁能帮忙?
在我编辑/etc/hosts.allow之后,我开始出现这个错误。
看到之前,我修好了之后。
ALL: 192.168.1 notice no period after 192.168.1
ssh_exchange_identification: Connection closed by remote host
ALL: 192.168.1. see the extra period after 192.168.1.
[email protected]'s password: Welcome to Linux Mint 11 Katya (GNU/Linux 2.6.38-8-generic i686)
我知道这个问题有点古怪,但是因为它还没有被接受的答案,所以在Koding.com连接到VM机器的例子中,这个解决scheme适用于我:
改变你的.ssh/config文件
从:
Host *.kd.io User myusername ProxyCommand ssh %[email protected] nc %h %p
至:
Host *.kd.io User myusername ProxyCommand ssh [email protected] nc %h %p
注意2件事情:
percent_expand: unknown key %r我改变%r到我的用户名 我正在运行Centos6
我能想到的最有可能的事情就是保证你没有说你检查的地方是你的authorized_keys文件的所有权。 检查/home/me/.ssh/是700,里面的文件是600(不可访问组),并拥有“我”。 尝试使用-vvv来更详细地解释ssh在那个时候正在做什么。
确保你以root身份运行sshd -t 。 如果我作为用户运行它,我得到“无法打开主机密钥”错误。 否则,请确保/ etc / ssh / ssh_host _ * _ key是root:root和600,但.pub键是root:root 644
我认为selinux在你连接之前会对非标准端口持怀疑态度,但为防万一,如果启用了selinux,请检查/var/log/audit.log。
how_to_generate_keygen:
$ ssh-keygen -t dsa -P “” -f ~/.ssh/id_dsa
请通过普通用户或root用户尝试上面的命令。
祝你好运。
如果您的sshd服务不可操作,您可以获得“ssh_exchange_identification:由远程主机closures的连接”!
如果您有权访问服务器,请检查您的sshd服务是否正在运行:
ps aux | grep ssh
并检查它正在端口22上收听:
netstat -plant | grep :22
更多细节在这里