How to change SSH port in Linux?

Chris Worner

Well-known member
Registered
Joined
Apr 15, 2016
Messages
612
Points
28
I read many recommendations to change the port on my VPS Linux for security reason. Because if I don't change I can get a lot of brute force attack, my original port is 22. If you change to another port, then they may skip my VPS and go find for another victim or maybe they need time to find the port? How can I change ssh port in Linux?
 

sh-admin

Active member
Registered
Joined
Sep 29, 2016
Messages
66
Points
0
In order to change the SSH port open the /etc/sshd/sshd_config file with either nano or vi command

search for "Port" option and you should see the default value of 22 there .. change it it your desire value save and exit the file ...

restart the sshd service on your server ..make sure you will open that new port for SSH in your firewall that is Iptables or CSF restart the firewall ..

now open another SSH session and try to connect the server with the new port that you have just assigned.

and it should work.
 

LJSHost

Well-known member
Hosting Provider
Registered
Joined
Jul 5, 2016
Messages
1,031
Points
63
Even if your firewall is banning repeated brute force attempts is always a good idea to change the default port. Most port scanning is automated using default port.
This should shut down 70% of scans attempted logins.
 

Chris Worner

Well-known member
Registered
Joined
Apr 15, 2016
Messages
612
Points
28
In order to change the SSH port open the /etc/sshd/sshd_config file with either nano or vi command

search for "Port" option and you should see the default value of 22 there .. change it it your desire value save and exit the file ...

restart the sshd service on your server ..make sure you will open that new port for SSH in your firewall that is Iptables or CSF restart the firewall ..

now open another SSH session and try to connect the server with the new port that you have just assigned.

and it should work.
Even if your firewall is banning repeated brute force attempts is always a good idea to change the default port. Most port scanning is automated using default port.
This should shut down 70% of scans attempted logins.
Thank you for sharing me tips on changing port in Linux.

Just one more question, does changing ports in Linux affect to softwares or tools work?
 

LJSHost

Well-known member
Hosting Provider
Registered
Joined
Jul 5, 2016
Messages
1,031
Points
63
If you have software that has a connection setting for the SSH port then yes, these settings will need to be updated.
It's hard to advise further without knowing exactly what software you are running on your server.
 
Older Threads
Latest Threads

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