Connection Refused on CentOS7 Linode after changing SSH port
I just deployed a CentOS7 Linode and changed my default ssh port from 22 to 42895. I followed this Community Post but I'm getting a connection refused
error when I try to ssh in. How do I resolve this?
1 Reply
There are a few factors that can generate a connection refused
error message and a few of them include:
- Your SSH service is down.
- You have the wrong credentials.
- The port you're trying to use is closed.
- SSH isn't installed on your server or
- Firewall setting are preventing an SSH connection to the server.
This guide here explains the points listed above into more details. CentOS has a built in firewall that needs to be reconfigured after the port has been changed.
After going through this community post to change your SSH port, proceed with the following commands below:
semanage port -a -t ssh_port_t -p tcp 42895
firewall-cmd --permanent --remove-service=ssh
firewall-cmd --permanent --add-port=42895/tcp
firewall-cmd --reload
Next, restart your ssh service with systemctl restart sshd
and follow up with checking the status to make sure its running with systemctl status sshd
.
Proceeded to ssh into the Linode with this new port number: ssh username@Linode IP -p 42892
replacing username
and LInodeIP
with your username and Linode IP respectively. This instructions can be found in this guide as well -How to Change Default SSH Port in CentOS / RHEL 8
With your connection being refused, you will have to make these changes by connecting to the Linode via the LISH console.