Securing your server from automated brute force attacks can be achieved by changing the default SSH port, 22. This guide walks you through the entire process of safely editing your SSH configuration. You'll update firewall permissions, ensure the new port functions properly, and confirm that your original connection can be closed.

Step 1: Access Your Server Dashboard

Log into your Server Monkey control panel and navigate to your VPS management section. Click on your active VPS instance to access the server management interface.

Step 2: Connect via SSH Terminal

Open the SSH terminal from your Server Monkey dashboard or use your preferred SSH client. Ensure you're connected as root or a user with sudo privileges for configuration changes.

Step 3: Edit SSH Configuration File

Open the SSH daemon configuration file using the nano text editor with administrative privileges. Navigate to the Port configuration line which is commented out by default.
Bash
 
 
sudo nano /etc/ssh/sshd_config

Step 4: Modify the Port Setting

Locate the line containing "#Port 22" and remove the hash symbol to uncomment it. Change the port number from 22 to your desired port (recommended: 2222, 2200, or any port between 1024-65535).

Step 5: Save Configuration Changes

Press Ctrl + X to exit nano, then press Y to confirm saving changes. Press Enter to confirm the filename and save the modified configuration file.
step5_save_changes.png

Step 6: Update Firewall Rules

Configure your firewall to allow connections on the new SSH port before restarting the service. Use UFW (Uncomplicated Firewall) to add the new port rule for TCP connections.
Bash
 
 
sudo ufw allow 2222/tcp sudo ufw reload

 

Step 7: Restart SSH Service

Restart the SSH daemon service to apply the new port configuration changes. Verify the service status to ensure it's running properly on the new port.
Bash
 
 
sudo systemctl restart sshd sudo systemctl status sshd

Step 8: Verify New Port is Active

Check that SSH is listening on your new port using the ss command. The output should show your new port number in the listening state.
Bash
 
 
ss -tuln | grep 2222

Step 9: Test New SSH Connection

Open a new terminal window and test connecting to your server using the new port. Keep your original SSH session open until you confirm the new connection works properly.
Bash
 
 
ssh -p 2222 username@your-server-ip
 
 
 
 
 
Important Notes:
Never close your original SSH session until you've confirmed the new port works correctly
Choose a port number between 1024-65535 to avoid conflicts with system services
Update any automated scripts or monitoring tools with the new SSH port number
Consider using SSH key authentication for additional security beyond port changes
 
 
 
Помог ли вам данный ответ? 0 Пользователи нашли это полезным (0 голосов)