我想通过ssh连接我的共享主机。因此,我在cpanel的ssh操作中生成了一个ssh密钥并进行了授权。然后,我下载了私钥并将其放入了我的MacBook的./ssh文件夹中。我使用以下代码来连接我的主机。
ssh -p 2083 username@host IP
但我遇到了这个错误:
kex_exchange_identification: Connection closed by remote host
我该如何解决我的问题?
我想通过ssh连接我的共享主机。因此,我在cpanel的ssh操作中生成了一个ssh密钥并进行了授权。然后,我下载了私钥并将其放入了我的MacBook的./ssh文件夹中。我使用以下代码来连接我的主机。
ssh -p 2083 username@host IP
但我遇到了这个错误:
kex_exchange_identification: Connection closed by remote host
我该如何解决我的问题?
sshd -t
命令,这将以调试模式运行sshd守护进程。该命令报告说我的密钥权限无效。然后,我只需要进入存储密钥的文件夹并执行chmod 0600 <your_ssh_keys>
命令即可。也许你运行的操作也会生成错误权限的内容。当我使用远程主机的docker命令时,我遇到了这个错误
docker -H ssh://user@server compose up
经过一番探索,我在我的远程服务器的认证日志中(/var/log/auth.log)发现了以下内容:
Aug 8 14:51:46 user sshd[1341]: error: beginning MaxStartups throttling
Aug 8 14:51:46 user sshd[1341]: drop connection #10 from [some_ip]:32992 on [some_ip]:22 past MaxStartups
/etc/ssh/sshd_config
中的MaxStartups
设置。重新启动SSH服务后,一切都像魔术般地运作。#Windows
ProxyCommand "C:\APP\Git\mingw64\bin\connect" -S 127.0.0.1:51837 -a none %h %p
#MacOS
#ProxyCommand nc -v -x 127.0.0.1:51837 %h %p
Host github.com
User git
Port 443
Hostname ssh.github.com
# change the path here
IdentityFile "C:\Users\Your_User_Name\.ssh\id_rsa"
TCPKeepAlive yes
Host ssh.github.com
User git
Port 443
Hostname ssh.github.com
# change the path here
IdentityFile "C:\Users\Your_User_Name\.ssh\id_rsa"
TCPKeepAlive yes
我曾经遇到过同样的问题,原因是我在ssh配置文件中使用了ProxyCommand
。在我的情况下,Host
没有正确定义,导致了相同的错误!