Changing the SSH port for dedicated servers is a good security practice to enhance protection against unauthorized access.

Here are the steps you can follow:

 

1. Connect to Your Server via SSH:

If you’re using Windows, you can use a program like PuTTY.

For iOS, simply use the terminal.

Connect to your server using the following command:

ssh username@your_server_ip

 

 

Replace "Username" with your actual username and "your_server_ip" with the server’s IP address.

 

2. Edit the SSH Configuration File:

Open the SSH configuration file using a text editor. For example:

sudo nano /etc/ssh/sshd_config

 

 

Look for the line that reads:

#Port 22

 

Remove the # symbol to uncomment the line.

 

3. Specify the New Port:

Change the number 22 to your desired port value. The valid range for the port is from 0 to 65535.

For instance, if you want to use port 57343, modify the line to:

Port 57343

 

Save the updated configuration file and exit the editor. For example:

In nano, use "CTRL+X", then "y" and finally hit the "Enter" key

 

6. Test the New SSH Port:

Temporarily disable the firewall to test the new port:

service iptables stop
service ip6tables stop

 

Reload the SSH service:

service sshd reload

netstat -tulpn | grep sshd

 

Verify that the new port is working

 

7. Enable the Firewall

 

If the new port works fine, start the firewall again:

service iptables start
service ip6tables start

8. Test Connectivity:

 

Without closing the current SSH session, try connecting using the new port.

If successful, you can drop port 22 from the SSH access list:

iptables -A INPUT -j DROP -p tcp --dport 2

 

Remember to adapt these steps to your specific server environment and requirements. Changing the SSH port adds an extra layer of security, but ensure you keep a record of the new port for future access. 

هل كانت المقالة مفيدة ؟ 0 أعضاء وجدوا هذه المقالة مفيدة (0 التصويتات)

Powered by WHMCompleteSolution