# Fixing SSH Errors

Learn how to resolve some of the most common errors you may receive when connecting to a server with [SSH](https://www.ionos.ca/digitalguide/server/tools/ssh-secure-shell/ "SSH: Secure Shell").

## WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED

This error is triggered when the [SSL certificate](https://www.ionos.ca/digitalguide/websites/website-creation/ssl-certificate/ "SSL certificate") for a server changes. The error is designed to flag a potential ["man in the middle"](https://www.ionos.ca/digitalguide/server/security/man-in-the-middle-attack-an-overview-of-attack-patterns/ "Man-in-the-middle attack: an overview of attack patterns") attack. However, most people only encounter the error after rebuilding a server.

If your server is new, or has had its image reinstalled since the last time you connected, simply click to accept the new SSL certificate and continue.

## Access Denied or Authentication Refused

The most common cause of the "Access Denied" or "Authentication Refused" error is that the SSH username or password has been misspelled or is incorrect.

- Verify that you have typed the username correctly.
- Make sure you are using the right username.
- Double-check the password. To be sure you are entering it correctly, copy and paste it into the field. Note: You can paste to the command prompt using Shift+Enter.

**Finding the Initial Root Password for a Linux Cloud Server**

If you have a Linux Cloud Server, the initial default root password is listed on the Control Panel.

Log in to your IONOS account, click **Control Panel** to open up the drop-down menu, then click **Cloud Panel.**

[![Image: Dropdown - Cloud Panel](https://www.ionos.ca/digitalguide/fileadmin/_processed_/1/2/csm_root-1_37be2dccb3.webp "Dropdown - Cloud Panel")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/root-1.jpg)      On the **Servers** page, click to select your server.

[![Image: select your server](https://www.ionos.ca/digitalguide/fileadmin/_processed_/d/f/csm_root-2_72ba188eb8.webp "select your server")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/root-2.jpg)      Scroll down to the **Initial Password** line and click **Show Password** to display the default root password.

[![Image: Show Password](https://www.ionos.ca/digitalguide/fileadmin/_processed_/2/c/csm_root-3_9d0af9cc32.webp "Show Password")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/root-3.jpg)      You can copy and paste the password from the pop-up message.

[![Image: opy and paste the password](https://www.ionos.ca/digitalguide/fileadmin/_processed_/c/3/csm_root-4_6cb5397a53.webp "opy and paste the password")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/root-4.jpg)      ---

### Note

If you have changed the password for root, the new password will not be shown here.

---

## Port 22: Connection refused

There are several possible reasons why you might receive the "Port 22: Connection refused" error when you try to connect via SSH to your server.

### Is the Server Accessible

The first thing you should do is find out if the server is allowing connections to port 22 from elsewhere on the Internet. Use the tool at [http://www.infobyip.com/sshservertest.php](http://www.infobyip.com/sshservertest.php "infobyip.com"), to check your server.

If this site is able to connect to your server, then the problem is on your end. You may be behind a firewall that blocks traffic on port 22. Many offices and schools block this port for security reasons.

If the site is not able to connect to your server, then the problem is either on the server, or between the server and the internet.

### Is SSH Installed

If this is a new installation, the SSH server (sshd) may not be installed. You can check to see if it is on your system with the command:

```none
which sshd
```

If the system responds with a path like /usr/sbin/sshd then the SSH server has been installed. If instead it responds with an error like /usr/bin/which: no sshd in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin) then you will need to install both the SSH client and the SSH server.

On Ubuntu and Debian, install these programs with the command:

```none
sudo apt-get install openssh-server openssh-clients
```

On CentOS, install these programs with the command:

```none
sudo yum -y install openssh-server openssh-clients
```

### Start or Restart SSH

Check to make sure that the SSH service is running with the command:

```none
sudo ps -aux | grep sshd
```

In addition to your grep command, you should see the SSHD process running.

[![Image: SSHD process](https://www.ionos.ca/digitalguide/fileadmin/_processed_/6/9/csm_ssh-port-22-sshd-running_b79823de2c.webp "SSHD process")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/ssh-port-22-sshd-running.jpg)      If the SSHD process is not running, start it.

- On Ubuntu and Debian: sudo service ssh start
- On CentOS: sudo systemctl start sshd

If the SSHD process is running, it may need to be restarted.

- On Ubuntu and Debian: sudo service ssh restart
- On CentOS: sudo systemctl restart sshd

### Is SSH Listening on Port 22

Port 22 is the default port for SSH connections. If your server's SSH daemon has been configured to listen to a port other than port 22, it will refuse SSH connections to port 22.

To check which port SSH is listening to, use the command:

```none
sudo netstat -apn | grep sshd
```

The output of this command will show you which port SSH is listening to.

[![Image: which port SSH is listening to](https://www.ionos.ca/digitalguide/fileadmin/_processed_/f/2/csm_ssh-port-22-netstat-which-port-ssh-is-listening-to_85c1807c14.webp "which port SSH is listening to")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/ssh-port-22-netstat-which-port-ssh-is-listening-to.jpg)      If SSH is listening to a port other than port 22, you will need to adjust your connection settings accordingly.

In PuTTY for Windows, you can set the port in the main Settings screen.

[![Image: PuTTY for Windows](https://www.ionos.ca/digitalguide/fileadmin/_processed_/1/4/csm_ssh-port-22-change-putty-configurations_38e04caee6.webp "PuTTY for Windows")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/ssh-port-22-change-putty-configurations.jpg)      ###  Check the SSH configuration file for typos

If you recently edited your SSH configurations, check the syntax of the file with:

```none
sudo sshd –T
```

### Examine your firewall rules

There are several possible firewall scenarios which could result in this SSH error, including:

- If you recently installed or updated a firewall on your server, you may have blocked SSH access to port 22 (or failed to allow it) by accident.
- If your server has recently been rebooted, your firewall rules may not have been loaded on boot to allow traffic to port 22.

### Check UFW rules

If you are using ufw as a firewall on your server, you can list all of your ufw rules with the command:

```none
sudo ufw verbose
```

You can allow SSH with the command:

```none
sudo ufw allow ssh
```

### Check Iptables rules

To see if you have an iptables rule which is blocking SSH traffic, use the command:

```none
sudo iptables -L | grep ssh
```

You can also list all of your iptables rules with the command:

```none
sudo iptables -L
```

To delete an iptables rule, edit the /etc/sysconfig/iptables file, then reload the iptables configuration with the command:

```none
sudo iptables -F
```

### Check your cloud panel firewall policy

Log in to your IONOS Control Panel and go to your Cloud Panel. Go to **Infrastructure -&gt; Servers** and click to select your server.

[![Image: Cloud Panel Infrastructure](https://www.ionos.ca/digitalguide/fileadmin/_processed_/7/0/csm_ssh-port-22-click-to-select-server_9fdd94f4f4.webp "Cloud Panel Infrastructure")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/ssh-port-22-click-to-select-server.jpg)      Scroll down to see if it has a Firewall Policy listed.

[![Image: Firewall Policy](https://www.ionos.ca/digitalguide/fileadmin/_processed_/f/5/csm_ssh-port-22-show-firewall-policy_a6a70deebf.webp "Firewall Policy")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/ssh-port-22-show-firewall-policy.jpg)      If a Firewall Policy is listed, edit this policy to allow SSH connections.

To do this, click **Network -&gt; Firewall Policies**.

[![Image: Firewall Policies](https://www.ionos.ca/digitalguide/fileadmin/_processed_/9/b/csm_ssh-port-22-network-firewall-policies_1b4c233b45.webp "Firewall Policies")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/ssh-port-22-network-firewall-policies.jpg)      Click to select the Firewall Policy that is assigned to your server.

[![Image: select the Firewall Policy](https://www.ionos.ca/digitalguide/fileadmin/_processed_/5/2/csm_ssh-port-22-select-firewall-policy_4d0175e0a8.webp "select the Firewall Policy")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/ssh-port-22-select-firewall-policy.jpg)      If your Firewall Policy does not have a rule to allow SSH, scroll down and click **Add Predefined Values**.

[![Image: Add Predefined Values](https://www.ionos.ca/digitalguide/fileadmin/_processed_/8/d/csm_ssh-port-22-add-predefined-value_cb7fcd7057.webp "Add Predefined Values")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/ssh-port-22-add-predefined-value.jpg)      Click **SSH**.

[![Image: Click SSH](https://www.ionos.ca/digitalguide/fileadmin/_processed_/9/c/csm_ssh-port-22-add-ssh_90db83bce2.webp "Click SSH")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/ssh-port-22-add-ssh.jpg)      Click the green check mark to add this new rule to your Firewall Policy.

[![Image: add this new rule to your Firewall Policy](https://www.ionos.ca/digitalguide/fileadmin/_processed_/5/d/csm_ssh-port-22-green-check-mark_c4e9e8df95.webp "add this new rule to your Firewall Policy")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/ssh-port-22-green-check-mark.jpg)      ##  Network error: Software caused connection abort

The "Network error: Software caused connection abort" error happens when your desktop machine closes the connection unexpectedly. This may happen if you experience an internet problem, including a brief hiccup in the connection.

It can also happen when the server stops listening. Your desktop sends several packets to the server before it gives up on the connection and closes the session.

## Write failed: broken pipe Network error: Connection reset by peer

When an SSH session closes with either "Write failed: broken pipe" or "Network error: Connection reset by peer," it means the session has timed out.

The timeout can occur on your computer, on the server, or on a firewall between them. The SSH session will automatically be closed if it sits idle for too long.

The solution is to set your SSH client to send "keepalive packets." These are small packets of data which are automatically sent at regular intervals. This tells the network that your connection is still active.

## Setting Keepalive

**PuTTY on Windows**

If you are using PuTTY on Windows to connect to your server, you can set the timeout under Connection. Set “Seconds between keepalives (0 to turn off)” to 60.

[![Image: set the timeout](https://www.ionos.ca/digitalguide/fileadmin/_processed_/7/6/csm_putty-config-timeout_5793c775dd.webp "set the timeout")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/putty-config-timeout.jpg)      **Linux or Unix**

If you are using a Linux or Unix desktop to connect to your server, edit /etc/ssh/sshd\_config and add:

```none
ServerAliveInterval 60
```

Save and exit the file, then restart SSH for the changes to take effect.

## Network error: Connection timed out

The "Network error: Connection timed out" error means that your SSH client did not receive any response from the server. There are several possible reasons for this error:

**An internet outage at your location**

Wait a few moments, then try again. If you still get the error message, check your internet connection by visiting a website like Google in your browser.

**A serious network problem somewhere between your location and the server**

You can check the health of the connection between your location and the server by running a traceroute. This will send a few packets of data to your server, and report back on the number of hops the data had to make, and how long it took for each hop.

- **Windows 10**

To run a traceroute on Windows 10, right click the **Start** button.

[![Image: Windows Start](https://www.ionos.ca/digitalguide/fileadmin/_processed_/4/a/csm_tracert-1_cd288e5683.webp "Windows Start")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/tracert-1.jpg)      Click **Search**.

[![Image: search](https://www.ionos.ca/digitalguide/fileadmin/_processed_/d/f/csm_tracert-2_90927635e2.webp "search")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/tracert-2.jpg)      Type "cmd" in the search field.

[![Image: Geben Sie "cmd" in das Suchfeld ein](https://www.ionos.ca/digitalguide/fileadmin/_processed_/f/0/csm_tracert-3_0ba2749f4e.webp "Geben Sie "cmd" in das Suchfeld ein")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/tracert-3.jpg)      Click **Command Prompt** when it appears.

[![Image: Click Command Prompt when it appears](https://www.ionos.ca/digitalguide/fileadmin/_processed_/0/e/csm_tracert-4_5df53984ee.webp "Click Command Prompt when it appears")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/tracert-4.jpg)      Run a traceroute to your server with the command:

```none
tracert [IP address or domain name]
```

For example, if your server is http://example.com the command would be:

```none
tracert example.com
```

The output will look something like this:

[![Image: Traceroute output](https://www.ionos.ca/digitalguide/fileadmin/_processed_/e/d/csm_tracert-5_73b901d8b5.webp "Traceroute output")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/tracert-5.jpg)      If you see extremely high ping times (anything greater than 300ms is considered "high") or excessive dropped packets (which are indicated with an asterisk), this could be the source of your problem.

Note: The final "hop" to the end server often shows dropped packets and "Request timed out" even when the server is up and running without any problems. For security reasons, most servers do not respond to ping commands.

**Firewall rules prevent the connection**

If you are behind a firewall at home or at work, this can cause the issue. You will also want to be sure that your server's firewall is configured to allow SSH connections.

**The server may be offline or shut down**

Give it a few moments and try to reconnect. If your server has been rebooted, it should be back online shortly.

If the server still does not respond, you can check the server's status from your IONOS Control Panel.

Log in to your IONOS account, click **Control Panel** to open up the drop-down menu, then click **Cloud Panel.**

On the **Servers** page, click to select your server. The **Status** light will be green for a server which is up and running. It will change to yellow or red if there are problems.

To check on the server, click the **Actions** button, then select **Access KVM Console** from the drop-down menu.

[![Image: Access KVM Console ](https://www.ionos.ca/digitalguide/fileadmin/_processed_/5/6/csm_kvm-1_e0d251d60b.webp "Access KVM Console ")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/kvm-1.jpg)      This will open the KVM console, which allows you to access your server as if you were sitting at a keyboard attached to the physical machine.

If you want to restart the server, you can do so from the KVM console with the command:

```none
sudo shutdown -r now
```

You can also restart your server from the **Actions** menu by clicking **Restart.**

[![Image: Restart](https://www.ionos.ca/digitalguide/fileadmin/_processed_/7/1/csm_kvm-2_32f14e902e.webp "Restart")](https://www.ionos.ca/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/kvm-2.jpg)


This is a markdown version of: [https://www.ionos.ca/digitalguide/server/know-how/fixing-ssh-errors/](https://www.ionos.ca/digitalguide/server/know-how/fixing-ssh-errors/) for AI/LLM consumption.