Linux mint ssh 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

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.

Источник

Fix: ssh connection refused port 22

SSH stands for Secure Shell, which creates a connection between the server & client. This connection can be used to communicate or transfer media/files through the server and client. In certain situations, users face the “Connection refused port 22” message during connecting servers. By default, the SSH service runs on port 22, which is a secure medium to transfer sensitive data. This article will explain all feasible solutions to tackle the “ssh connection refused port 22” error, along with reasons.

The content carried this post is as follows:

  • How to Fix the “ssh connection refused port 22” Error?
  • Reason 1: OpenSSH is not installed
  • Solution: Install OpenSSH in System
  • Reason 2: SSH Server Not Active
  • Solution: Check the Active Status of SSH
  • Reason 3: SSH Service is Running on a Different Port
  • Solution: Check the SSH Port Number
  • Reason 4: Firewall is Blocking Port 22
  • Solution: Configure Firewall Through UFW Utility

How to Fix the “ssh connection refused port 22” Error?

The “ssh connection refused port 22” error arises during the establishing connection to a server. There are many other reasons, such as incorrect “username”, “IP address”, “Internet connection”, and many more. Some technical reasons with solutions are discussed as follows. Before digging into the details, let’s look at what the error looks like:

Читайте также:  Linux find in filesystem

Reason 1: OpenSSH is not installed

In the Linux systems, the OpenSSH packages are not installed by default. The missing SSH (server, client) is one reason for this error.

Solution: Install OpenSSH in System

To resolve the issue, install the ssh services on the operating system. To do so, execute the below script for installing the “OpenSSH” packages:

$ sudo apt install openssh-server

After executing the command, users can connect to the system on port 22.

Install OpenSSH on Other Linux Distributions

For other Linux distributions, including RHEL/Centos/Fedora, OpenSSH can be installed by executing the below script:

$ sudo yum install openssh-server

Let’s carry on to another error.

Reason 2: SSH Server Not Active

Another reason may cause the “SSH” server not to respond actively. For this, the request will never reach the required destination for executing the communication process. It is due to the server not working.

Solution: Check the Active Status of SSH

A solution is provided to check the current status of SSH through the “systemctl” command. It is quite useful to display the complete information, including “Main PID”, “Tasks”, “Memory”, “CPU”, and “Port”.

$ sudo systemctl status ssh

The output shows that the current status is “active(running)”. Else, you can execute the below scripts to active it:

$ sudo systemctl start ssh #Start SSH Service $ sudo systemctl enable ssh #Enable SSH Service $ sudo systemctl restart ssh #Restart SSH Service

Reason 3: SSH Service is Running on a Different Port

It may be a reason that SSH services are running on one port and users requesting through a different port. Due to this problem, Port 22 will not respond to the particular request and display an error.

Solution: Check the SSH Port Number

A solution is provided here to find the SSH Port number through the “sshd_config” configuration file. For instance, the “Nano Editor” is utilized to open this configuration file by following the below script:

$ sudo nano /etc/ssh/sshd_config

After executing the script, it pops up the “sshd_config” configuration file on which you can verify the SSH Port number 22.

Читайте также:  Аналог компаса на линукс

Once the port number is confirmed, verify that the SSH service is listening to the same port. To do so, use the below-stated command:

Reason 4: Firewall is Blocking Port 22

If you cannot fix the problem through the above-stated solutions, then you should check the firewall and set its rule for port 22. So that it should allow all the connections over that port number

Solution: Configure Firewall Through UFW Utility

To add Port 22 over the firewall, which allows incoming SSH connection. To do so, execute the below script:

In our case, the rules are already added.

After adding the rules, you need to reload the firewall as follows:

To display the configured firewall after adding rules, run the command below:

Now, you can verify that the rules have been added by configuring the firewall through the ufw utility.

Conclusion

The “ssh connection refused port 22” error can be resolved by installing “OpenSSH” packages or checking the active status of SSH services or port numbers. Additionally, incorrect “username” and “IP address” cause the same error of connection refusal. Users can also edit the port number after accessing the “sshd_config” configuration file to make a new connection. This post has listed down all the possible reasons, and their solutions to fix the error “ssh connection refused port 22”.

Источник

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