Ssh подключение linux connection refused

How to solve ‘Connection refused’ errors in SSH connection?

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.

next time it craps out like that; run a ping on it again, does it still work? how many people ssh to this machine?

Читайте также:  Linux чем посмотреть smart

Exactly the same problem here, also getting a mix of successful connects (which then work for hours), ‘connection refused’ and ‘software caused connection abort’ after the login or password entry. To provide some additional details: in my case it’s a 64-bit virtual machine (running Ubuntu Server 10.10) on a Microsoft Hyper-V host, using the «old network card» emulation.

Источник

How to Fix Connection Refused by Port 22 Debian/Ubuntu

SSH provides a secure channel to access Linux servers. Sometimes we come across the error Connection refused while connecting to SSH servers. There could be several reasons behind the error like the SSH service is inactive, the port is blocked by UFW firewall, the server is using a different port, or because of some IP conflict. Today, we will explore different ways we can resolve the Connection Refused issue on an Ubuntu/Debian system.

Verify OpenSSH Installation on Your Linux System

First, check if OpenSSH is installed on your system or not. The command mentioned below will verify it.

If OpenSSH is installed, you will see the following output on the terminal.

In case OpenSSH is not installed, we will install it by executing the following command:

Check SSH Service

Let’s now check what’s the status of the SSH service on our system. It should be active or in the running state. The reason why you are getting a connection refused error could be the inactive state of SSH on your system. Run the following command to check the status:

The output tells us it is in the active (running state).

Читайте также:  Arch linux starting version

If your SSH service is inactive, you can start it by executing the following commands:

Check SSH Server Listening Port

Perhaps, you are connecting to the wrong port which is why you are getting a connection refused error. For example, the server is listening for a connection on port 1068 but you are trying to connect to port 22.

Before trying to connect, first, verify which port is being used by the SSH server to listen to new connections. If the server is listening on default port 22, then you can use the following command syntax to make a connection:

Issue the following command to check on which port the OpenSSH server is listening:

As we can see 22 port is in use by OpenSSH to listen to connections.

In case, some other port is being used in place of 22, you will issue the command like this:

Allow SSH in Firewall

A connection refused message could also be because the firewall on your system is blocking the SSH port. To allow the port through firewall, execute this command:

If a port other than 22 is being used, you will issue the command like this:

Once the rules are updated, you will get this output on the terminal:

Reload the firewall with this command to update the rules:

Now check the status of firewall to verify if the SSH port has been allowed or not.

You will see the following message if you are using port 2244 for SSH:

Resolve Duplicate IP Address Conflict

Another reason that may be causing this issue is a duplicate IP address. So, we need to verify if the system has a duplicate address or not. To do that, we need arping utility on our system. Install it using the following command:

Читайте также:  Сгенерировать хеш пароля linux

Now, ping the server IP address using the command syntax below:

If you receive a reply from more than one MAC address, that means a duplicate IP address is running on the system. To resolve this issue, change the IP of the SSH server.

Conclusion

In today’s guide, we discussed several reasons that could be causing the Connection refused error and several ways to resolve this issue. This article will surely help you in troubleshooting the error.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.

Источник

Оцените статью
Adblock
detector