Ssh сетевая ошибка в соединении отказано

купил виртуальный хост, дали мне ip-адрес, логин и пароль, только подключится к нему немогу, сразу после нажатия появляется консоль и выскакивает ошибка — «PuTTY Fatal Error — Network error: Connection refused» как исправить? может кто-то сталкивался с таким и знайтет как решить
техподержка говорит что я неверно пароль ввожу, этого быть не может, все тщательно проявлял. Брандмауэр Защитника Windows отключал. Толку ноль!

OS: Windows 10,
Клиент: PuTTY

введите сюда описание изображения

введите сюда описание изображения

UPD:
через браузер заходит.
По SSH не работает. Подключится могу лишь через VPN или через 3G-интернет.

введите сюда описание изображения
введите сюда описание изображения

задан 18 ноя 2017 в 19:09

Kill Noise's user avatar

Kill NoiseKill Noise

1,2046 золотых знаков22 серебряных знака48 бронзовых знаков

17

Наиболее вероятную причину в лице хулиганящего провайдера уже указали, но можно собрать ещё чуть больше информации с помощью plink.exe (входит в состав PuTTY):

  1. Откройте консоль cmd
  2. Выполните plink -v ваш_хост

В ответ plink выдаст дополнительную информацию по используемому при подключении протоколу, что также позволит отсечь некоторые причины, типа устаревшего обмена ключами.

Пример подключения:

C:ProgramsPuTTY>plink -v <...>
Looking up host "<...>"
Connecting to <...> port 22
We claim version: SSH-2.0-PuTTY_Release_0.67
Server version: SSH-2.0-OpenSSH_7.5p1 Ubuntu-10
Using SSH protocol version 2
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-256
Host key fingerprint is:
ssh-rsa 2048 45:f8:02:48:a0:76:db:93:1a:a4:1a:70:ea:1f:5f:71
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 45:f8:02:48:a0:76:db:93:1a:a4:1a:70:ea:1f:5f:71
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n) n
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA-256 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA-256 server->client MAC algorithm
login as: Disconnected: No username provided
^C

ответ дан 27 ноя 2017 в 14:37

Lyth's user avatar

LythLyth

1,6501 золотой знак10 серебряных знаков18 бронзовых знаков

7

По большей видимости у Вас настроен Firewall на внешний интерфейс на сервере. Чтобы разрешить подключение к 22ому порту на Ubuntu (во многих версиях) достаточно выполнить команды:

$ sudo ufw allow 22
$ sudo ufw enable

Если же у Вас нету возможности выполнить или действия выше ни на что не повлияли, то Вам следует связаться с Вашим хостинг-провайдером для решения данной проблемы.

p.s. В таких случаях подключение может блокировать и провайдер, если ничего уж не помогает, то советую связаться с ним

ответ дан 22 ноя 2017 в 13:33

Владислав Метрояннов's user avatar

1

  1. Проверить Ping — доступен ли вообще сервер с вашего IP — Проверили — работает (непонятно только почему winMTR пишет no response)
  2. Зайти в консоль управления сервером из браузера, проверить диапазоны IP адресов, с которых разрешен доступ к серверу. — web консоли управления виртуальным сервером, я так понимаю, нету (а то, что Apache2 на Ubuntu стоит — это очень хорошо — It works!)
  3. Если нет web консоли — связаться с провайдером у которого сервер покупали и выяснить, как они сами туда подключаются, поднят ли SSH, и с каких IP адресов доступно подключение по SSH (может быть еще что-то дополнительно в настройках нужно указать, вообще-то, для SSH нужен не только логин-пароль, а еще пара .pem ключей — один у вас — один на сервере). Проверили — SSH поднят, и .pem ключи не нужны, т. к. с другого устройства подключение есть без них. Осталось проверить диапазоны IP адресов с которых доступно SSH подключение. Настроить их можно например с того же телефона.

ответ дан 27 ноя 2017 в 14:08

0

SSH is a network protocol that allows you to securely access and manage a remote system over a network. While connecting to a remote machine via SSH, you might have encountered the «connection refused» error. Experiencing this issue can be frustrating especially if you are a system admin and have to perform some tasks on the remote system on an urgent basis.

Let’s look at some of the possible causes of getting the SSH «connection refused» error and methods to resolve it.

1. Check if an SSH Server Is Installed

One possible cause of the «connection refused» error is that the remote machine is not running an SSH server. Without the SSH server, the machine will not accept incoming SSH connections, and you will not be able to access it remotely.

So the very first step in troubleshooting the error is to check whether an SSH server is installed on the remote machine. Use the following command to verify the SSH server installation:

On Debian-based distributions:

 dpkg --list | grep ssh 

On RHEL-based distributions:

 yum list installed | grep ssh 

On openSUSE:

 zypper search -i | grep ssh 

On Arch-based distributions:

 pacman -Q | grep ssh 

If the SSH server is installed on the remote machine, you will see it listed in the output. Otherwise, you must install the OpenSSH server on the remote machine you want to access via SSH. OpenSSH is an open-source version of the SSH tools for remotely accessing and controlling systems.

To install the OpenSSH server, use the following commands:

On Debian-based distributions:

 sudo apt install openssh-server 

On RHEL-based distributions:

 sudo yum install openssh-server 

On openSUSE:

 sudo zypper install openssh 

On Arch-based distributions:

 pacman -S openssh 

2. Check the SSH Service Status

Another reason for getting the «connection refused» error can be that the SSH service is disabled or not running on the remote machine. Once you are sure that the SSH server is installed, the second thing you need to check is the status of the server.

 sudo systemctl status sshd 

If the service is up and running, the output will indicate it as active (running). Otherwise, you will see something like inactive (dead).

status of SSH server

If the SSH server is not running, you can start it manually using the following command:

 sudo systemctl start sshd 

You can also enable the service to automatically start at boot with:

 sudo systemctl enable sshd 

3. Check the SSH Port

By default, the SSH server runs on port 22. However, one can change the default port. Therefore, if you receive the SSH «connection refused» error, it may be because you are attempting to connect to the SSH server on the default port 22 while it is running on some different port.

You can use the netstat command with grep to find the port the SSH server is listening on:

 sudo netstat -plntu | grep ssh 

check ssh port

You can also find the SSH port from the sshd_config file using the following command:

 grep port /etc/ssh/sshd_config 

After identifying the correct SSH port, try connecting to your remote system using that specific port.

4. Check Your System Firewall

Most of the connectivity problems occur due to your machine’s firewall blocking some ports or services. If the remote machine has the SSH server installed and running, the next step is to check your firewall.

To figure out whether the firewall is blocking the connection, temporarily disable the firewall using the following commands:

On Debian and Arch-based Linux distributions:

 sudo ufw disable 

On RHEL-based distributions and openSUSE:

 sudo systemctl disable firewalld 

If the error does not appear after disabling the firewall, it means that the firewall was blocking the connection. In this case, re-enable the firewall and add a rule that allows SSH.

On Debian and Arch-based Linux distributions, use the following command to allow SSH in the UFW firewall:

 sudo ufw allow ssh 

Alternatively, you can also allow SSH by the port number in the firewall. Let’s say the SSH server is using port 5555, then you would use the following command to allow it in the firewall:

 sudo ufw allow 5555 

To verify if the rule has been added successfully, check the UFW status:

 sudo ufw status 

On RHEL-based distributions and openSUSE, use the following command to allow SSH in the firewall:

 sudo firewall-cmd --permanent --add-service=ssh 

To allow SSH by port number, use the following command:

 sudo firewall-cmd --permanent --add-port={port}/tcp 

For an SSH server running on port 4444, the command would be:

 sudo firewall-cmd --permanent --add-port=4444/tcp 

To verify the successful addition of the rule in the firewall, run:

 sudo firewall-cmd --list-all 

5. Resolve IP Address Conflicts

There is also a chance of the SSH «connection refused» error occurring due to the SSH server IP conflicting with another system’s IP in the network. This happens when two systems on a network claim to have same the IP address, resulting in an IP conflict.

To confirm if there is an IP conflict in your network, use the arp-scan tool as follows:

 arp-scan [network-id] 

If there is an IP conflict, you will see the duplicate IP address in the output. The below screenshot is an example of an IP conflict in a network:

using arp-scan to find duplicate ip

To avoid IP conflicts, make sure no devices have static IP addresses that overlap with the DHCP pool addresses.

Bonus Tip: Run SSH in Verbose Mode

Whenever you encounter an SSH error, try running the ssh command in verbose mode to track down the issue. To run SSH in verbose mode, use the ssh command with the -vvv option as follows:

 ssh -vvv username@ip_address 

ssh debug

In verbose mode, you will see debugging messages in each step of the connection that will help you understand where the problem lies.

Troubleshooting the SSH «Connection Refused» Error on Linux

By identifying the potential causes of the SSH connectivity error and implementing the suggested solutions, you will be able to troubleshoot and resolve the SSH «connection refused» error. In addition to these steps, make sure you are connecting to the correct IP address and using the right login credentials.

To make your remote connection more secure, you can set up two-factor authentication for SSH on Linux.

Резюмируя вышесказанное (и немного отсебятины) — открываем терминал и выполняем команды. На второй команде он может спросить пароль, это нормально, пробуем ввести свой. Если не подошёл, то ищем того, кто ставил убунту и дальше мучаем его :)
1. Проверяем, есть ли в процессах, собственно, сервер SSH
ps aux | grep ssh
Если видим в выводе только эту команду, ставим OpenSSHd
sudo apt-get install openssh-server
Если написал, что is already the newest version, то пробуем запустить
sudo service ssh restart
ps aux | grep ssh
Если не появился, то вывод следующих команд в студию:
cat /etc/ssh/sshd_config
tail -10 /var/log/syslog

2. Если в выводе ps aux есть что-то вроде /usr/sbin/sshd -D, то
sudo netstat -4nlp | grep sshd
Если там не 0.0.0.0:22, а, например 0.0.0.0:2222, то меняем порт в PuTTY на 2222 (а ещё можно исправить в sshd_config, но это потом)
Если всё ОК, то остался файерволл
sudo iptables-save
и вывод в студию

I have an Ubuntu Server 10.10 32-bit in my home. I’m making SSH connections to it from my PC via Putty.

The problem is, sometimes I’m able to login seamlessly. However, sometimes it gives me an error like this: Network error: Connection refused.

Then, I dont’t change anything, try to login a few times more, wait a while and try again. Sometimes I can log in, sometimes I cannot. It seems pretty random to me.

What can I do to solve this?

Edit:

And Sometimes, Putty gives Network error: Software caused connection abort error after displaying login as: text.

Here is the ping -t output:

Pinging 192.168.2.254 with 32 bytes of data:
Reply from 192.168.2.254: bytes=32 time=6ms TTL=64
Reply from 192.168.2.254: bytes=32 time=65ms TTL=6
Reply from 192.168.2.254: bytes=32 time=88ms TTL=6
Reply from 192.168.2.254: bytes=32 time=1ms TTL=64
Reply from 192.168.2.254: bytes=32 time=3ms TTL=64
Reply from 192.168.2.254: bytes=32 time=1ms TTL=64
Reply from 192.168.2.254: bytes=32 time=1ms TTL=64
Reply from 192.168.2.254: bytes=32 time=1ms TTL=64
Reply from 192.168.2.254: bytes=32 time=1ms TTL=64

I turned off firewall of router, and everything seems to work now. Except for that, I still can’t enter my web server by typing external IP from my PC.

Secure Shell (SSH) is a key WordPress development tool. It grants advanced users access to key platforms and software that make coding and other tasks easier, faster, and more organized.

So if you attempt to use SSH only to see a “Connection refused” error, you may start to feel concerned. However, this is a common issue, and it’s entirely possible to fix it on your own with just a bit of troubleshooting. You’ll be back to running commands in no time flat.

In this post, we’ll discuss what SSH is and when to use it. Then we’ll explain some common reasons your connection may be refused, including in PuTTY. Finally, we’ll provide some troubleshooting tips.

Let’s dive in!

Prefer to watch the video version?

What Is SSH and When Should I Use It?

Secure Shell (SSH), also sometimes called Secure Socket Shell, is a protocol for securely accessing your site’s server over an unsecured network. In other words, it’s a way to safely log in to your server remotely using your preferred command-line interface:

ssh login example

Using SSH to remotely access a WordPress site hosted on Kinsta

Unlike File Transfer Protocol (FTP), which only enables you to upload, delete, and edit files on your server, SSH can accomplish a wide range of tasks. For instance, if an error locks you out of your WordPress site, you can use SSH to access it remotely.

This protocol also enables you to use several key developer tools, including:

  • WP-CLI. The WordPress command line. You can use it for a variety of tasks, including new installations, bulk plugin updates, and media file imports.
  • Composer. A PHP package manager. It enables you to implement several frameworks for use in your site’s code by pulling the necessary libraries and dependencies.
  • Git. A version control system used to track changes in code. This is especially useful for teams of developers working together on a single project.
  • npm. A JavaScript package manager. It includes a command-line and JavaScript software registry. Note: Kinsta customers will need an Enterprise plan in order to access this feature.

It’s important to note that using SSH is an advanced skill. Generally speaking, lay users of WordPress should contact their developers or hosting providers for help, rather than trying to resolve issues with SSH themselves.

Why Is My SSH Connection Refused? (5 Reasons for Connectivity Errors)

Unfortunately, there are many scenarios that could occur while you’re trying to connect to your server via SSH, which might result in an error reading “Connection refused”.

Below are some of the most common issues that might be causing problems for you.

1. Your SSH Service Is Down

In order to connect to your server with SSH, it must be running an SSH daemon – a program that runs in the background to listen for and accept connections.

If this service is down, you will not be able to successfully connect to your server and may receive a Connection refused error:

connection refused error

Connection Refused error in Terminal

Your server’s SSH daemon may be down for a wide variety of reasons, including unexpected traffic spikes, resource outages, or even a Distributed Denial of Service (DDoS) attack. In addition to the troubleshooting steps we’ll mention below, you may want to contact your hosting provider to determine the root cause of the issue.

If you suspect that your SSH service might be down, you can run this command to find out:

sudo service ssh status

If the command line returns a status of down, then you’ve likely found the reason behind your connectivity error.

2. You Have the Wrong Credentials

Although it may seem too simple to be true, it’s possible that you’re just entering the wrong credentials when trying to connect to your server. There are four pieces of information needed to run SSH:

  • Host name. The IP address of the server you’re trying to connect to or your domain name.
  • Username. Your (S)FTP username.
  • Password. Your (S)FTP password.
  • Port. The default port is 22. However, some hosting providers (including Kinsta) change their SSH port number for security reasons. If this is the case, you should be able to find it by logging in to your MyKinsta dashboard.

You can also check to see which port is being used for SSH by running this command:

grep Port /etc/ssh/sshd_config

The command line should return the correct port.

Check to make sure you’re entering the right credentials and taking into account the possibility of typos or entering the wrong IP address or port.

3. The Port You’re Trying to Use Is Closed

A “port” is simply the endpoint to which you’re directed when connecting to your server. In addition to making sure you have the correct one, you’ll also want to check to see if the port you’re trying to use is open.

Any open port is a security vulnerability, as hackers can try to exploit it and gain access to the server. For this reason, unused ports are often closed to prevent attacks.

In the event that port 22, or the custom SSH port for your server, has been closed, you will likely see a Connection refused error. You can see all the ports listening on your server by running this command:

sudo lsof -i -n -P | grep LISTEN

This command should return a list of ports with the LISTEN state. Ideally, you want to see port 22 or your server’s custom SSH port listed here. If it’s not, you’ll need to reopen the port in order to connect to your server.

4. SSH Isn’t Installed on Your Server

As we briefly mentioned earlier, servers use SSH daemons to listen for and accept connections. Therefore, if the server you’re trying to connect to doesn’t have one installed, you won’t be able to access it using SSH.

Generally speaking, almost all hosting providers will have SSH daemons installed on their servers by default. This particular issue is more common on localhost or dedicated servers.

5. Firewall Settings Are Preventing an SSH Connection

Since open ports present a security risk, firewalls installed to protect servers from hackers sometimes block connections to them. Unfortunately, this means that even harmless users who are trying to SSH into their servers may receive a Connection refused error as a result of firewall settings.

If your setup appears to be in order and you still can’t connect, take a look at your firewall’s rules. You can display them in your command-line interface with the following commands:

sudo iptables-save # display IPv4 rules
sudo ip6tables-save # display IPv6 rules

Your results will vary, but you’ll want to look for these elements to determine if your firewall is blocking SSH connections:

  • dport 22: This refers to the destination port, which for SSH is usually port 22 (reminder: Kinsta doesn’t use this port number).
  • REJECT: This would indicate that connections are being refused from the specified destination.
  • DROP: Like REJECT, this means that connections to the relevant port are being blocked.

If you search the results of the commands above for dport 22, you should be able to determine if your firewall is preventing an SSH connection. If so, you’ll have to change the rules to accept requests.

Why Does PuTTY Say Connection Refused?

PuTTY is an SSH client. If you’re familiar with FTP, this platform is the FileZilla equivalent to SSH on Windows machines. In other words, PuTTY enables users to input their credentials and launch an SSH connection:

download putty

The PuTTY website

If you’re a PuTTY user and see the Connection refused error, the cause is likely one of those listed above.

This is an SSH connectivity error like any other, and the troubleshooting tips below should work whether you’re using PuTTY, Terminal, or any other program for connecting to your server with SSH.

We’ve taken our knowledge of effective website management at scale, and turned it into an ebook and video course. Click to download The Guide to Managing 60+ WordPress Sites!

How Do I Troubleshoot SSH Connectivity Errors?

When you’re experiencing an SSH connectivity error, there are a few steps you can take to troubleshoot it depending on the cause. Here are some tips for troubleshooting the reasons for a Connection refused error that we covered above:

  • If your SSH service is down. Contact your hosting provider to see why your SSH service isn’t running. For localhost or dedicated servers, you can use the command sudo service ssh restart to try to get it running again.
  • If you entered the wrong credentials. Once you’ve double-checked the SSH port using the grep Port /etc/ssh/sshd_config command, try connecting again with the correct details.
  • If your SSH port is closed. This is usually a side effect of one of the two reasons listed below. Either install an SSH daemon on the server you want to connect to or change your firewall rules to accept connections to your SSH port.
  • If SSH isn’t installed on your server. Install an SSH tool such as OpenSSH on the server you want to connect to using the sudo apt install openssh-server command.
  • If your firewall is blocking your SSH connection. Disable the firewall rules blocking your SSH connection by changing the destination port’s settings to ACCEPT.

If you’re attempting to connect to your hosting provider’s server, it may be wiser to contact support than to try troubleshooting the problem yourself. Users on localhost or dedicated servers may be able to find further support on more advanced forums if none of the above solutions works.

Are you getting the ‘Connection refused’ error over SSH? Learn why that’s happening and how to troubleshoot SSH connectivity errors thanks to this guide 🙅 ✋Click to Tweet

Summary

Being able to connect to your server with SSH is convenient in a wide range of situations. It can enable you to access your site when you’re locked out of your WordPress dashboard, run commands via WP-CLI, track changes in your site’s code with Git, and more.

Although there are several causes that could be behind your SSH connectivity error, these are a few of the most common:

  1. Your SSH service is down.
  2. You have the wrong credentials.
  3. The port you’re trying to use is closed.
  4. SSH isn’t installed on your server.
  5. Firewall settings are preventing an SSH connection.

Понравилась статья? Поделить с друзьями:
  • Ssd ошибка установки windows 0xc0000005
  • Ssd не инициализируется выдает ошибку
  • Srs ошибка мерседес что это такое
  • Srs volvo 2019 xc60 ошибка
  • Srs airbag service urgent volvo xc90 как сбросить ошибку