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 ssh restart into shell.
Done.
__________________
Need a good host?
Find one here -->
List of the Best Web Hosts in 2012 - Shared, reseller and VPS hosting