Skip to content

Welcome to the ultimate guide for setting up an Ubuntu Server! This step-by-step manual will help you install, configure, and secure your server, making sure it's ready for production or personal use. Whether you're a beginner or experienced, follow along to get your server up and running smoothly.

License

Notifications You must be signed in to change notification settings

7ROBE/Ubuntu-Server-Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Ubuntu Server Complete Setup Guide

Welcome to the ultimate guide for setting up an Ubuntu Server! This step-by-step manual will help you install, configure, and secure your server, making sure it's ready for production or personal use. Whether you're a beginner or experienced, follow along to get your server up and running smoothly.

Overview

This guide will walk you through the following:

  • Installing and configuring OpenSSH for remote access
  • Setting a static IP address
  • Installing essential software for server security and performance
  • Setting up Samba to share the root directory
  • Best practices for server management and regular maintenance

Let's get started!

Step 1: Update System

Before starting, make sure the system is up to date.

sudo apt update && sudo apt upgrade -y

Step 2: Install OpenSSH

OpenSSH allows you to remotely access your server. To install it, run:

sudo apt install openssh-server -y

Once installed, check the status to ensure the service is running:

sudo systemctl status ssh

If not running, start and enable the service to launch on boot:

sudo systemctl start ssh
sudo systemctl enable ssh

Step 3: Configure Static IP Address

To ensure your server always uses the same IP address, you’ll need to set a static IP.

  1. Identify the Network Interface: Use the following command to list network interfaces:

    ip a

    Identify your main interface (e.g., eth0 or ens160).

  2. Modify the Netplan Configuration: Open the Netplan configuration file:

    sudo nano /etc/netplan/00-installer-config.yaml

    Update it with your network information:

    network:
      version: 2
      ethernets:
        <interface_name>:
          dhcp4: no
          addresses:
            - <your_static_ip>/24
          gateway4: <your_gateway>
          nameservers:
            addresses:
              - <your_dns_server>

    Replace <interface_name>, <your_static_ip>, <your_gateway>, and <your_dns_server> with your specific values.

  3. Apply the Configuration:

    sudo netplan apply
  4. Test the Connection: Verify the server's connection by pinging an external address:

    ping 8.8.8.8

Step 4: Access Your Server Remotely

You can now access your server from another machine using SSH:

ssh <your_username>@<your_server_ip>

Step 5: Install and Configure Samba

Samba allows you to share files across different operating systems, such as Windows. To share the root directory with full access, follow these steps carefully:

1. Install Samba

Install Samba with the following command:

sudo apt install samba -y

2. Backup the Samba Configuration

Before making changes, it's a good idea to backup the default Samba configuration file:

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

3. Edit the Samba Configuration File

Open the Samba configuration file to set up sharing of the root directory:

sudo nano /etc/samba/smb.conf

Add the following at the end of the file:

[Root]
   path = /
   available = yes
   valid users = <your_username>
   read only = no
   browsable = yes
   public = yes
   writable = yes
   force user = root

Make sure to replace <your_username> with the username you want to grant access to.

4. Set Samba Password for User

You need to set a Samba password for your user:

sudo smbpasswd -a <your_username>

5. Restart Samba Service

To apply the changes, restart the Samba service:

sudo systemctl restart smbd

6. Access the Shared Directory

From a Windows machine, access the server's shared directory by typing the server's IP in File Explorer:

\<your_server_ip>

Log in with the username and password you created for Samba.

Step 6: Install Recommended Software

Below are some useful software tools for managing and optimizing your server.

1. Fail2Ban

Fail2Ban monitors logs and bans IPs that show malicious signs, such as repeated failed login attempts.

sudo apt install fail2ban -y

You can adjust its settings in /etc/fail2ban/jail.conf to suit your security needs.

2. UFW (Uncomplicated Firewall)

UFW is an easy-to-use firewall tool to manage access to your server.

sudo apt install ufw -y
sudo ufw allow OpenSSH
sudo ufw enable

3. Docker

Docker allows you to run applications in isolated containers, which is great for deploying and testing software environments.

sudo apt install docker.io -y
sudo systemctl start docker
sudo systemctl enable docker

4. htop

htop is an interactive system monitor that provides a detailed view of system processes and resource usage.

sudo apt install htop -y

5. net-tools

The net-tools package includes networking utilities like ifconfig, useful for debugging network issues.

sudo apt install net-tools -y

6. Apache or Nginx (Web Server)

You can install either Apache or Nginx, depending on your preference.

  • Apache:

    sudo apt install apache2 -y
  • Nginx:

    sudo apt install nginx -y

7. Database Server (MySQL or PostgreSQL)

Install a database server based on your application needs.

  • MySQL:

    sudo apt install mysql-server -y
  • PostgreSQL:

    sudo apt install postgresql postgresql-contrib -y

8. certbot (SSL Certificates)

certbot allows you to easily manage SSL certificates from Let’s Encrypt.

For Nginx:

sudo apt install certbot python3-certbot-nginx -y

For Apache:

sudo apt install certbot python3-certbot-apache -y

Step 7: Server Management and Maintenance

Monitoring Server Logs

Keep track of server logs using journalctl:

sudo journalctl -xe

Regular Updates

To keep your server secure and up to date, periodically run:

sudo apt update && sudo apt upgrade -y

You can also enable automatic security updates:

sudo apt install unattended-upgrades -y

Edit the config file:

sudo dpkg-reconfigure --priority=low unattended-upgrades

Recommendations and Best Practices

To keep your server running smoothly, follow these best practices:

  1. Regular Backups: Always perform regular backups of critical data using tools like rsync or backup services.
  2. Security Hardening: Use tools like Fail2Ban, and consider setting up SSH keys for more secure authentication.
  3. Monitor Performance: Utilize htop or other monitoring tools to ensure your server is performing well under load.
  4. Use Docker for Deployment: Docker containers can isolate applications, making deployments cleaner and easier to manage.
  5. Test on a Local Server First: If possible, deploy new services and applications on a test server before moving to production.

Conclusion

Your Ubuntu Server is now set up with OpenSSH for remote access, a static IP address for consistent networking, Samba for file sharing, and several recommended tools for improving security, performance, and management. Follow the best practices to maintain your server’s health and security over time. Keep your system updated, monitor performance, and secure access to prevent unauthorized activities.

With this setup, you're ready to run a stable and secure server environment. Enjoy your newly configured Ubuntu Server!

About

Welcome to the ultimate guide for setting up an Ubuntu Server! This step-by-step manual will help you install, configure, and secure your server, making sure it's ready for production or personal use. Whether you're a beginner or experienced, follow along to get your server up and running smoothly.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages