I cannot connect to my server via ssh using my computer, but I can connect to this server via my cell phone using termius app. I have checked /etc/hosts.allow and /etc/hosts.deny and my iptables, and I have alse searched google, it seems no answer fits this problem. I don't know how to solve it , here is ssh -v 183.17.228.80 output
debug1: Connecting to 183.17.228.80 [183.17.228.80] port 22.
debug1: Connection established.=======================
debug1: permanently_set_uid: 0/0
debug1: SELinux support disabled
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
ssh_exchange_identification: read: Connection reset by peerI can ping this server, here is telnet
telnet 183.17.228.29 22
Trying 183.17.228.29...
Connected to 183.17.228.29.
Escape character is '^]'.
Connection closed by foreign host. 11 15 Answers
Just reboot your server which you want to ssh. It worked for me, previously I was facing the same issue.
5That actually means that your IP is blacklisted by the server. Try to whitelist your IP address to be able to login. You may take a look at the /etc/hosts list to see if your server's ip address have changed.
5I had the same issue but after restarting the sshd daemon I could connect to host.
sudo systemctl restart sshd && systemctl status sshdThis is only a temporary workaround until you increase the MaxAuthTries parameter.
1The way I solved the problem is I went to the host machine and ran a few commands.
sudo mkdir /var/run/sshd
sudo chmod 755 -R /var/run/sshd
sudo service ssh restartI got connected to the machine after that.
It looks like ssh daemon on the server is hung. Are you sure it is running? When you telnet to ssh, you have to see a signature. Something like:
telnet unixhow.com 22
Trying 35.228.26.20...
Connected to unixhow.com.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.1What I see from your output is ssh daemon not responding on server side. I recommend to connect via IP-KVM (or in some other way) to the remote machine and restart sshd.
3The above error happen when you have limit of failed try to authenticate to the server and you have too many ssh keys on your client (more than value of MaxAuthTries)
What you can try is to increase the value of MaxAuthTries and restart sshd daemon. Or you can limit the number of keys in your ~/.ssh directory and use subdirectories and ~/.ssh/config file to define key per host/group of hosts
This could be because you do not have an openssh server running on your ubuntu. You can run the below command to check the status of your openssh server.
ubuntu@ubuntu:~$ sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2019-03-20 11:52:16 GMT; 5min ago Process: 1034 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS) Main PID: 1058 (sshd) Tasks: 1 Memory: 5.1M CPU: 122ms CGroup: / └─1058 /usr/sbin/sshd -D
Mar 20 11:52:15 ubuntu systemd[1]: Starting OpenBSD Secure Shell server...
Mar 20 11:52:16 ubuntu sshd[1058]: Server listening on 0.0.0.0 port 22.
Mar 20 11:52:16 ubuntu sshd[1058]: Server listening on :: port 22.
Mar 20 11:52:16 ubuntu systemd[1]: Started OpenBSD Secure Shell server.
Mar 20 11:52:24 ubuntu sshd[1131]: Connection closed by 10.0.2.2 port 60566 [preauth]
Mar 20 11:53:59 ubuntu sshd[1135]: Accepted password for ubuntu from 10.0.2.2 port 60654 ssh2
Mar 20 11:53:59 ubuntu sshd[1135]: pam_unix(sshd:session): session opened for user ubuntu by (uid=0)
Mar 20 11:57:48 ubuntu sshd[1238]: Accepted password for ubuntu from 10.0.2.2 port 61124 ssh2
Mar 20 11:57:48 ubuntu sshd[1238]: pam_unix(sshd:session): session opened for user ubuntu by (uid=0)If the status is not active (running), you might want to install and/or start the openssh-server. You can do so with the commands shown below.
sudo apt update
sudo apt install openssh-server My solution is add my local IP address to the /etc/hosts.allow:
sshd:192.168.10.88:allowthis works for me.
There may be many reasons but one of most possible reason can be(in my case it was) ssh / port 22 is not allowed by firewall.
You can allow ssh connection by User-interface (some providers allow that) or If you have any alternative method to login (Ex. digitalocean provide a console button ) you can run below command
sudo ufw allow ssh
sudo ufw allow 22 I'm using my cellular hot spot to connect to the web, while I was working the console froze, and I couldn't connect any more ssh_exchange_identification: read: Connection reset by peer
I tried to reset the SRV but it didn't help
Only when I change my network connection (to a hotspot on a different cellular) I could connect again.
NOTE: I can still use the old connection to connect to SRVs on a different AWS, strange...
To solve the issue, proceed as follows:
- Reboot your server from server online terminal.
If this does not work,
- Edit the file
$HOME/.ssh/known_hosts - Delete any content inside this file, when it will reconnect to any servers you ssh then you must re-accept connections.
I had this same thing happen, and needed to ssh -v 'ip addr' and then i saw that i needed to accept the certificate. Also may be an ACL or route rule blocking putty: example -
Putty client has 10.x.x.x addr with firewalls blocking enterprise network from talking to DMZ hosts, but your cell phone at 58.x.x.x whatever public ip address can talk to the dmz host youre trying to reach.
so I'd look at the ssh -v info when you try to connect again, see if you can glean any info, and then check if there are rules keeping you from getting to your server at a firewall or router level, not in a denyhosts file on the server itself.
Create an new ssh key pair for user authentication. SSH Keys and Public Key Authentication guide
Just follow the guide.
1- Check that sshd in installed and running of the server.
- Make sure that the daemon is installed and started.You must be able to 'man sshd'. I think that package it is in is open-ssl, and you will need to start the daemon ( and stop it when you don't need it.).
After many days, I do not know what was the problem in the end, perhaps I really had too many tries and had to wait. Or it was another thing, like a missing openssh installation. I posted a working guide how to use ssh to download a git repo here, with the core of it as follows:
# first image only to download the git repo
FROM alpine as MY_TMP_GIT_IMAGE
RUN apk add --no-cache git
RUN mkdir -p /root/.ssh && chmod 700 /root/.ssh
COPY /.ssh/id_ed25519 /root/.ssh/id_ed25519
RUN chmod 600 /root/.ssh/id_ed25519
RUN apk -yqq add --no-cache openssh-client && ssh-keyscan -t ed25519 -H gitlab.com >> /root/.ssh/known_hosts
RUN git clone :GITLAB_USERNAME/test.git
RUN rm -r /root/.ssh
# Start of the second image
FROM MY_BASE_IMAGE
COPY --from=MY_TMP_GIT_IMAGE /MY_GIT_REPO ./MY_GIT_REPO