Welcome to Internetport! This guide will walk you through the essential steps to secure and configure your newly provisioned Virtual Private Server (VPS). Following these instructions will help ensure that your server is up-to-date, secure, and ready for deployment.
1. Connect to Your VPS via SSH
To begin, you'll need to connect to your VPS using Secure Shell (SSH). You can do this from a terminal on Linux or macOS, or by using an SSH client like PuTTY on Windows.
- Open your terminal or SSH client.
- Use the following command to connect, replacing
your_ip_addresswith your VPS's IP address androotif you're using the root user:
ssh root@your_ip_address
2. Update Your System Packages
Keeping your system up-to-date is crucial for security and performance.
- If you're using a Debian-based system (like Ubuntu), run:
apt update && apt upgrade -y
- If you're using a Red Hat-based system (like CentOS or Fedora), use:
yum update -y
3. Create a New User with Sudo Privileges
For security reasons, it's best to avoid using the root user for daily tasks.
- Create a new user:
adduser your_username
- Add the user to the sudo group:
usermod -aG sudo your_username
Switch to Your New User
After creating a new user, switch to it using:
su - your_username
4. Configure the Firewall
A firewall is essential for controlling incoming and outgoing network traffic.
- If you're using UFW (Uncomplicated Firewall) on Ubuntu, enable it:
sudo ufw enable
- Allow SSH connections:
sudo ufw allow ssh
For CentOS/RHEL with Firewalld
- Start and enable firewalld:
sudo systemctl start firewalld
sudo systemctl enable firewalld
- Add SSH to the firewall rules:
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
5. Enable Automatic Security Updates
Automatic updates help keep your system secure by applying patches and updates automatically.
- For Ubuntu, install unattended-upgrades:
sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
- For CentOS/RHEL, enable the yum-cron service:
sudo yum install yum-cron
sudo systemctl enable yum-cron
sudo systemctl start yum-cron
6. Set Your Server's Hostname
A hostname is useful for identifying your server.
- To set the hostname, use:
sudo hostnamectl set-hostname your_hostname
Troubleshooting
- SSH Connection Issues: Ensure that SSH is running and that you're using the correct IP address and credentials.
- Firewall Configuration Errors: Double-check your firewall rules to ensure they are correctly configured. Use
sudo ufw statusorsudo firewall-cmd --list-allto review them. - Update Failures: Verify that your package lists and repositories are up-to-date and accessible.
By following these steps, you'll have a secure and well-configured VPS ready for your applications. If you encounter any issues or need further assistance, please contact our support team.