Adding ports for SSH

Ask questions about dedicated servers here and we and other users will do our best to answer them. Please also refer to the self-help section for tutorials and answers to the most commonly asked questions.
Potcat
A semi-regular
A semi-regular
Posts: 28
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Sat Apr 20, 2013 6:05 am

Adding ports for SSH

Post by Potcat »

I wish to add ports for SSH to listen to, but unfortuantely I cannot get this working. I have tried adding the ports to SSH configs, tried various iptables rules, nothing is working. Is there an extra step I might be missing?
User avatar
Edge100x
Founder
Founder
Posts: 12945
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Adding ports for SSH

Post by Edge100x »

It looks as though this is normally done with multiple Port lines in /etc/ssh/sshd_config (or your version of that file). For instance:

Code: Select all

Port 22
Port 50
Port 99
Port 6666
After making this change, you'd need to restart the SSH daemon (or the whole VDS).
Potcat
A semi-regular
A semi-regular
Posts: 28
Joined: Sat Apr 20, 2013 6:05 am

Re: Adding ports for SSH

Post by Potcat »

Edge100x wrote:It looks as though this is normally done with multiple Port lines in /etc/ssh/sshd_config (or your version of that file). For instance:

Code: Select all

Port 22
Port 50
Port 99
Port 6666
After making this change, you'd need to restart the SSH daemon (or the whole VDS).
This was the first thing I tried changing. Unfortunately it didn't work. I have since tried adding a few rules to the iptables, which also did not work, and moments ago I tried restarting the whole VDS (I had already tried restarting SSH), but this has not changed things at all.
User avatar
Edge100x
Founder
Founder
Posts: 12945
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Adding ports for SSH

Post by Edge100x »

Have you tried disabling your firewall entirely? Have you checked the output of "netstat -anp" to see if it's listening on the ports locally?
Potcat
A semi-regular
A semi-regular
Posts: 28
Joined: Sat Apr 20, 2013 6:05 am

Re: Adding ports for SSH

Post by Potcat »

I tried using netstat -anp |grep ssh (or something similar) and it seems like the ports are opened locally. And I think you have suggested disabling the firewall in another thread, and to be honest it just doesn't feel right, you know what I mean? I'm pretty sure I've written the firewall rules correctly anyway; they work for port 22 and my rules are quite literally the exact same thing but on different ports.
User avatar
Edge100x
Founder
Founder
Posts: 12945
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Adding ports for SSH

Post by Edge100x »

Temporarily disabling the firewall is a troubleshooting step. If disabling the firewall eliminates the problem, you'll know that you need to adjust it. If I suggested that you do this previously, and you chose not to, then you could have potentially avoided this entire thread and the wasted time it entailed by following my advice.

If the ports are open locally, on the correct IP(s), then it's a firewall issue.
Potcat
A semi-regular
A semi-regular
Posts: 28
Joined: Sat Apr 20, 2013 6:05 am

Re: Adding ports for SSH

Post by Potcat »

Edge100x wrote:Temporarily disabling the firewall is a troubleshooting step. If disabling the firewall eliminates the problem, you'll know that you need to adjust it. If I suggested that you do this previously, and you chose not to, then you could have potentially avoided this entire thread and the wasted time it entailed by following my advice.

If the ports are open locally, on the correct IP(s), then it's a firewall issue.
I've already tried that, I thought you offered that as a solution rather than a diagnostic. It doesn't help regardless.
User avatar
Edge100x
Founder
Founder
Posts: 12945
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Adding ports for SSH

Post by Edge100x »

Please post the netstat output.
Potcat
A semi-regular
A semi-regular
Posts: 28
Joined: Sat Apr 20, 2013 6:05 am

Re: Adding ports for SSH

Post by Potcat »

# netstat -anp | grep ssh
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1380/sshd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1380/sshd
tcp 0 0 0.0.0.0:2021 0.0.0.0:* LISTEN 1380/sshd
tcp 0 52 74.91.112.155:22 153.107.40.9:61335 ESTABLISHED 1933/sshd
tcp 0 0 :::80 :::* LISTEN 1380/sshd
tcp 0 0 :::22 :::* LISTEN 1380/sshd
tcp 0 0 :::2021 :::* LISTEN 1380/sshd
unix 3 [ ] STREAM CONNECTED 14277 1933/sshd
unix 3 [ ] STREAM CONNECTED 14276 1935/sshd
unix 2 [ ] DGRAM 14273 1935/sshd
User avatar
Edge100x
Founder
Founder
Posts: 12945
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Adding ports for SSH

Post by Edge100x »

When you use "ssh localhost:80", does that work?

What method did you use to try to disable the firewall?
Potcat
A semi-regular
A semi-regular
Posts: 28
Joined: Sat Apr 20, 2013 6:05 am

Re: Adding ports for SSH

Post by Potcat »

This is what I get when I write that SSH command.

ssh: Could not resolve hostname localhost:80: Name or service not known

As for the firewall, I used service iptables stop
User avatar
Edge100x
Founder
Founder
Posts: 12945
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Adding ports for SSH

Post by Edge100x »

Try ssh localhost -p 80, instead -- I made a mistake on the command.

For iptables, try "iptables --flush".
Potcat
A semi-regular
A semi-regular
Posts: 28
Joined: Sat Apr 20, 2013 6:05 am

Re: Adding ports for SSH

Post by Potcat »

Using the new SSH command, the server tried to connect to itself in typical SSH fashion (asked for a host key, etc), so I assume that means it's working locally.

Doing iptables --flush has achieved nothing however.
User avatar
Edge100x
Founder
Founder
Posts: 12945
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Adding ports for SSH

Post by Edge100x »

I'm not sure what else it could be apart from a firewall problem.

Is your Firewall page in the control panel blank?

Do you have SELinux running?
Potcat
A semi-regular
A semi-regular
Posts: 28
Joined: Sat Apr 20, 2013 6:05 am

Re: Adding ports for SSH

Post by Potcat »

Edge100x wrote:I'm not sure what else it could be apart from a firewall problem.

Is your Firewall page in the control panel blank?

Do you have SELinux running?
tried disabling and reenabling iptables, no luck.

Firewall page is blank.

No I do not have SELinux running.

This is becoming a tad frustrating; I really need to be able to access the server on these ports.
Post Reply