Reputation: 1500
I've wanted to connect my share hosting with ssh. So I generate an ssh key in the ssh action of cpanel and authorized it. Then I've downloaded the private key and drop it in the ./ssh folder of my MacBook.I've used this code to connect my host.
ssh -p 2083 username@host IP
but I got this error:
kex_exchange_identification: Connection closed by remote host
How can I solve my problem?
Upvotes: 21
Views: 159099
Reputation: 322
I just had the same problem and neither of the solutions above worked as the problem stemmed from somewhere else. It turned out the domain I tried to connect to (with cloudflare tunnels btw, i.e., with ProxyCommand), was not resolved. I am pihole and the external filters blocked the domain resolution for my SSH server. Hence, when I wanted to connect to the server, due to the blackholing of blocked domains, the IP it was resolved to was my localhost. So everytime I wanted to connect to that domain, it tried to connect to localhost.
The solution was to update my pihole container to the latest version and now it is working.
Upvotes: 0
Reputation: 2196
In my case I was trying to ssh to a Debian 12 VM. I survived the log, and find some logs maybe sounds like attak on my ssh
, So, I solve it by update openssh-server
on the VM.
sudo apt-get install openssh-server
and fixed it.
Upvotes: -1
Reputation: 11
In my case the host was also the reason - I used gitea as git server and the .ssh folder and all certs in it required to be not accessible for everyone.
This makes totally sense, but I wished that the error message would give a better hint!
Upvotes: 1
Reputation: 11
Not so sure if my solution is working for yours. For me, I plan to connect to github via ssh. The same error occurs. I find the solution in https://github.com/orgs/community/discussions/55269 My config file content is as below.
#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
Upvotes: 1
Reputation: 447
first, make sure if the hostname is correct. A typo either in the cmd or configfile gives this error.
then, check the sshd log in the host, to find the issues.
Upvotes: 1
Reputation: 1779
I had same problem and it was happend as I use ProxyCommand
in ssh config file. In my case the Host
was not defined correctly which then caused the same error!
Upvotes: 3
Reputation: 492
I got this error when using docker command with remote host
docker -H ssh://user@server compose up
after some digging i found on my remote server in auth logs (/var/log/auth.log) this:
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
This lead me to change MaxStartups
settings in /etc/ssh/sshd_config
. After restarting ssh service everything worked like a charm.
Upvotes: 6
Reputation: 165
I run into a similar case with a small computer I have in my desk. What I did to debug the issue was to run sshd -t
, which runs the sshd daemon in debug mode. This command reported that the permissions of my keys were invalid. All I had to do then was to go in the folder where the keys are stored and issue chmod 0600 <your_ssh_keys>
.
Maybe the action you run generated things with the wrong permissions too.
Upvotes: 15