Quantcast How to change SSH port (sshd) in Linux to increase VPS security - digitalFAQ Forum
  #1  
01-17-2012, 07:06 AM
lordsmurf's Avatar
lordsmurf lordsmurf is offline
Site Staff | Video
 
Join Date: Dec 2002
Posts: 7,740
Thanks: 806
Thanked 1,186 Times in 1,057 Posts
Changing the port away from the default 22 is one way to add security-by-obscurity to your VPS or dedicated web server. It's extremely simple, and you only need to change one line in the sshd config file, using your Linux text editor (like nano, vi, etc).

Step 1:
Log into SSH with Putty.

You must be logged in to view this content; either login or register for the forum. The attached screen shots, before/after images, photos and graphics are created/posted for the benefit of site members. And you are invited to join our digital media community.



Step 2:
See if a decent text editor is installed, such as nano.

Type nano at the shell prompt. If nano opens, great! Press CTRL+X and close it again. But if nano is not installed...

You must be logged in to view this content; either login or register for the forum. The attached screen shots, before/after images, photos and graphics are created/posted for the benefit of site members. And you are invited to join our digital media community.


... let's install it. In Ubuntu or Debian, you'll type apt-get install nano. For CentOS/RHEL, you'll type yum install nano.

You must be logged in to view this content; either login or register for the forum. The attached screen shots, before/after images, photos and graphics are created/posted for the benefit of site members. And you are invited to join our digital media community.



Step 3: Edit the sshd config, select new port.

Hackers and script kiddies like to look for the default port 22, and the poor alternative choice 2222, so pick something else. For example, 2255.
IMPORTANT: Pick a port not used by anything else! Find a port not listed here: http://en.wikipedia.org/wiki/List_of...P_port_numbers

At the shell prompt, type nano /etc/ssh/sshd_config and you'll find Port 22 near the top of the configuration file. Using your keyboard arrows (not mouse), move down to the line, and delete/backspace the old number, and type in a new one using the number row on your keyboard (not the number keypad).

Press CTRL+X to save. Press Y to confirm. Press ENTER to overwrite the old config file.

You must be logged in to view this content; either login or register for the forum. The attached screen shots, before/after images, photos and graphics are created/posted for the benefit of site members. And you are invited to join our digital media community.



Step 4: Config firewall (if present)

If you have a firewall installed, be sure to close off port 22, and add the new port. Restart the firewall service after Step 5. This quickie guide does not cover firewall usage or maintenance, because there are quite a few choices. CSF/LFD is my suggestion.


Step 5: Restart SSH.

Type service sshd restart into shell. Done.

__________________


Need a good web host? — Read our 2018 Review of the Best Web Hosts
Quite often, problems with web sites are caused by having a rotten web host. Worse yet, many hosts try to blame you (the customer) for the problems! So dump that lousy company. Say goodbye to slow sites, unresponsive support techs, and downtime. Find yourself a new host today. Whether you need shared, reseller, VPS, semi-dedicated, cloud, or dedicated hosting, something on our list should be a good upgrade for you.




- Did my advice help you? Then become a Premium Member and support this site.
- Find television shows, cartoons, DVDs and Blu-ray releases at the TVPast forums.
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Ads / Sponsors
 
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove unnecessary port access with CSF/LFD firewall in cPanel kpmedia cPanel WHM 0 01-12-2012 02:23 AM
How to change SMTP port: Exim, DirectAdmin, SquirrelMail and Roundcube kpmedia SSH for VPS/Dedicated (CLI) 0 01-10-2012 01:43 AM
Cannot unzip network file: 'Your current security settings do not allow this action' kpmedia Computers 0 09-08-2011 02:29 AM
Widen [code] box in vBulletin forum, change style to increase width kpmedia Website and Server Troubleshooting 0 07-25-2011 07:14 AM

Thread Tools



 
All times are GMT -5. The time now is 01:05 AM  —  vBulletin Copyright Jelsoft Enterprises Ltd