Skip to content

Instantly share code, notes, and snippets.

@jonahgeek
Created July 7, 2023 07:26
Show Gist options
  • Save jonahgeek/6bf4c73918c0b6b11fd8baa079191c01 to your computer and use it in GitHub Desktop.
Save jonahgeek/6bf4c73918c0b6b11fd8baa079191c01 to your computer and use it in GitHub Desktop.
Configure New VPS

Congratulations on your new VPS server running Ubuntu! Here are some essential steps you should take to set up your server:

  1. Update the system: Begin by updating the package repositories and upgrading all the installed packages on your server. This ensures that you have the latest security patches and bug fixes. Run the following commands:

    sudo apt update
    sudo apt upgrade
    
  2. Secure your server: Strengthen the security of your VPS by configuring the firewall and enabling only necessary network services. Ubuntu uses UFW (Uncomplicated Firewall) as a front-end to manage firewall rules. To enable UFW and allow SSH access, execute the following commands:

    sudo ufw enable
    sudo ufw allow OpenSSH
    
  3. Create a non-root user: Using the root account for day-to-day tasks is not recommended due to security risks. Create a new user with sudo privileges, and use that account for regular operations. Replace yourusername with the desired username in the following command:

    sudo adduser yourusername
    sudo usermod -aG sudo yourusername
    
  4. Configure SSH access: Modify the SSH configuration to enhance security. Open the SSH configuration file using a text editor like Nano:

    sudo nano /etc/ssh/sshd_config
    

    Make the following changes:

    • Set PermitRootLogin to no to disable root login.
    • Uncomment PasswordAuthentication and set it to no to enforce key-based authentication.
    • Optionally, change the SSH port by modifying Port (use a non-standard port for added security).

    Save the file and restart the SSH service for changes to take effect:

    sudo systemctl restart sshd
    
  5. Set up SSH key authentication: Generate an SSH key pair on your local machine if you haven't already done so. Copy the public key to your VPS server to enable key-based authentication:

    ssh-copy-id yourusername@your_server_ip
    
  6. Install useful software: Install essential software packages that are commonly used on Ubuntu servers. While the specific requirements vary depending on your use case, some common packages to consider include fail2ban for intrusion prevention, unattended-upgrades for automatic security updates, and htop for system monitoring.

These steps should provide a good foundation for setting up your VPS server. Remember to always keep your server updated, regularly backup your data, and follow security best practices to ensure a secure and stable environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment