Changing the SSH Port for Your Linux Server?

wpspeedster

Well-known member
Registered
Joined
May 6, 2016
Messages
120
Points
18
I just got a new VPS and want to change the SSH port for it to decrease brute force attacks. Can you guys share me ways to change this?
 

FerdieQO

Well-known member
Joined
Jul 15, 2016
Messages
213
Points
28
The default port for SSH is the TCP port 22. By modifying the default port, you are not only decreasing attacks, but also reduce the potential amount of traffic that attackers attach to your servers during a brute force attack. Port 22 is a general target port for SSH attacks.

To change the default port, you must edit the configuration file "sshd_config" in this folder /etc/ssh/
Use the commands below for editing:

Code:
nano /etc/ssh/sshd_config
Press Ctrl+W to search the string "port".

Code:
port 22
Once you have found the string, change it to a different port number at that line. For example, 1563.

Code:
port 1563
Note: Make sure that the port is not already being used by the server. The following command should show you whether your desired port has already been assigned (if you do not receive a response, this means that your port is free for using).

Code:
netstat -ntap | grep 1563
 

MilesWeb

Well-known member
Registered
Hosting Provider
Joined
Nov 14, 2016
Messages
266
Points
18
In order to activate the SSH/ Shell Access icon in the cPanel user area, you will first have to login to the VPS WHM.

Go to Packages > Feature Manager. You can either create a new list or edit the existing one and make sure to enable the ‘SSH Connection Window Option'. Click on the ‘Save' button in order to save the changes.

You will have to assign this feature list to all the accounts where you need the SSH/Shell Access icon to be displayed in cPanel.
 

VirtuBox

Well-known member
Registered
Joined
May 3, 2016
Messages
1,622
Points
83
I just got a new VPS and want to change the SSH port for it to decrease brute force attacks. Can you guys share me ways to change this?
FerdieQO answer is correct, but remember to disable the firewall or to add new rules for the new SSH port, or you will not have access to the server via SSH
 

fwh

Administrator
Staff Member
Joined
Dec 8, 2012
Messages
773
Points
63
fwh
You are right, I forgot this step before log out SSH after changed SSH port and restarted sshd

Normally we should use this command to update iptables

Code:
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 695 -j ACCEPT
thus I could not log into SSH on a VPS

Luckily I thought to ConfigServer Firewall&Security which I had got on my hosting control panel. Using this way, I could login back to ssh.

Enter ConfigServer Firewall&Security

Click on Firewall Configuration - Edit the configuration file for the csf firewall and lfd

Finding Allow incoming TCP ports and Allow outgoing TCP ports and adding new port there.

Save changes and restart the the csf firewall and lfd. All done!

Just sharing here if someone had same problem and know on how to solve it. :)
 

Dewlance

Well-known member
Hosting Provider
Registered
Joined
Dec 20, 2014
Messages
115
Points
18
You will be need to change port and If you are using CSF then you don't need to run iptables command and you can open port from CSF gui mode which is more easier.

Also try to use password less based login which does not allow to login to account via password and you will be need to use key file to access your account.
 
Older Threads
Latest Threads
Recommended Threads
Replies
1
Views
1,721
Replies
7
Views
3,925
Replies
3
Views
4,317
Replies
5
Views
2,571
Replies
1
Views
2,321

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top