Are you looking to make your server private? Keeping your server secure and private is essential for protecting sensitive data and ensuring that only authorized users have access. In this tutorial, we will explore different methods you can use to make your server private.
1. Change Default Ports
If you want to make your server more secure, consider changing the default ports for services such as SSH (Secure Shell) or FTP (File Transfer Protocol). Most attackers Target services running on default ports, so changing them can provide an extra layer of security.
Changing SSH Port
To change the SSH port on a Linux server, follow these steps:
- Login to your server using SSH.
- Edit the SSH configuration file by typing
sudo nano /etc/ssh/sshd_config
. - Locate the line that says
#Port 22
and uncomment it by removing the “#” symbol. - Replace “22” with your desired port number.
- Save the file and exit the editor.
- Restart the SSH service using
sudo service ssh restart
.
Changing FTP Port
To change the FTP port on a Windows server, follow these steps:
- Navigate to “Internet Information Services (IIS) Manager” in the Windows Administrative Tools.
- Select your FTP site from the connections pane on the left side.
- Click on “FTP Firewall Support” in the center pane.
- Change the “Data Channel Port Range” and “External IP Address of Firewall” fields to your desired port number.
- Click “Apply” to save the changes.
2. Use Firewall Rules
A firewall acts as a barrier between your server and potential threats.
By configuring firewall rules, you can control which IP addresses or networks have access to your server. Here are some common firewall solutions:
iptables (Linux)
To add a rule allowing access from a specific IP address using iptables, use the following command:
sudo iptables -A INPUT -s YOUR_IP_ADDRESS -j ACCEPT
Windows Firewall (Windows)
To create an inbound rule in Windows Firewall, follow these steps:
- Type “Windows Defender Firewall” in the search bar and open it.
- Select “Advanced settings” on the left side.
- Create an inbound rule by clicking on “Inbound Rules” in the left-side panel.
- Select “New Rule..” from the right-side panel.
- Select “Custom” and click “Next”.
- Select “All programs” and click “Next”.
- Select“These IP addresses”
# Allow specific IP address -A INPUT -s YOUR_IP_ADDRESS -j ACCEPT # Drop all other inbound traffic -A INPUT -j DROP
Save and exit the editor.
Restart the Iptables service to apply the new rules:
sudo service iptables restart
Windows Firewall (Windows)
To create an inbound rule in Windows Firewall, follow these steps:
- Type “Windows Defender Firewall” in the search bar and open it.
- Select “Advanced settings” on the left side.
- Create an inbound rule by clicking on “Inbound Rules” in the left-side panel.
- Select “New Rule.
- Select “Custom” and click “Next”.
- Select“All programs” and click “Next”.
- Select“These IP addresses”
# Allow specific IP address -A INPUT -s YOUR_IP_ADDRESS -j ACCEPT # Drop all other inbound traffic -A INPUT -j DROP
Save and exit the editor.
Restart the Iptables service to apply the new rules:
sudo service iptables restart
Windows Firewall (Windows)
To create an inbound rule in Windows Firewall, follow these steps:
- Type “Windows Defender Firewall” in the search bar and open it.
- Select “Advanced settings” on the left side.
- Create an inbound rule by clicking on “Inbound Rules” in the left-side panel.
- Select “New Rule.
- Select “Custom” and click “Next”.
- Select“All programs” and click “Next”.
- Select“These IP addresses”
# Allow specific IP address -A INPUT -s YOUR_IP_ADDRESS -j ACCEPT # Drop all other inbound traffic -A INPUT -j DROP -
Save and exit the editor.
- Select“These IP addresses”
# Allow specific IP address -A INPUT -s YOUR_IP_ADDRESS -j ACCEPT # Drop all other inbound traffic -A INPUT -j DROP -
Save and exit the editor.
Restart the Iptables service to apply the new rules:
sudo service iptables restart
3. Enable Two-Factor Authentication (2FA)
One of the best ways to secure