• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SwiftGuides

How-to Guides, Tutorials & Much More.

  • Home
  • Servers
  • Search
You are here: Home / Servers / Initial Server Setup with Ubuntu

Initial Server Setup with Ubuntu

July 17, 2025 by Sourabh Verma Leave a Comment

A new server is like an open land area where you will build an empire. As we all know, to make a building last long, we need a strong foundation. Here in this guide, we will perform the initial server setup with Ubuntu, which will add a strong foundation to our server. Whether you are working on a personal server or a server for a big firm, initial server configuration is the most important thing, as it will add a layer of security and make the server reliable.

When you think of a new server, remember that it’s just a PC with an Operating System (Ubuntu in our case). Therefore, we must install the required applications and configure them as these applications will allow or deny the required.

In this tutorial, we will cover the following

  • Prerequisites
  • Step 1 – Login to the server with SSH
    • With the root’s password
    • With SSH key
  • Step 2 – Create Sudo User
  • Step 3 – Installing and configuring the UFW firewall
  • Step 4 – Change SSH port
  • Conclusion

Prerequisites

  • A new Ubuntu server
  • Root access via SSH

Step 1 – Login to the server with SSH

The first step is to login to our Ubuntu server using SSH. You can use CMD (for Windows) or terminal (for Linux), or you can install Putty.

With the root’s password

Some hosting providers use key-based login, and some use root’s password. If your hosting provider has provided root’s password, then you can just open CMD or terminal and enter the below command.

ssh root@your_server_ip
Note:- Make sure to change "your_user_ip" with your server's IP

With SSH key

If your hosting provider has provided you with the SSH key, then the login steps are given below

  • Open Putty
  • On the left menu, click on “SSH”, then click on “Auth”, then click on “Credentials”
  • Add the SSH key under “Private key file for authentication.”
  • Click on “Session,” which is the first option given on the left side
  • Enter your server’s IP in the “Host Name (or IP address) field
  • Enter “22” in the “Port” field
  • Click “Open.”
  • Just enter your root’s password and hit the “Enter” key

With this, you have successfully connected to your server.

Step 2 – Create Sudo User

Always remember, the root user is the God of the server, as it has access to everything. It has high privileges and can perform any actions without any restrictions. Since we have to do a lot of work on the server, it would be very dangerous to work with the “root” user. A sudo user is the best way to manage a server, as they have the privileges to manage the server. Follow the steps below to create a sudo user

Execute the below command to create a new user first

adduser username

Now, let’s assign “sudo” privileges to the user we have created

usermod -aG sudo username
Note: make sure to change "username" to the username you want to create for ex: ashish

Step 3 – Installing and configuring the UFW firewall

Although there are many firewalls available but, in Ubuntu, “Ufw” works best, and hence we will install the same and configure it. Follow the steps below

# apt update -y
# apt upgrade -y
# apt install ufw -y

This will install ufw firewall on your server. Now, let’s configure it. Execute the commands given below, which will allow only the OpenSSH, 80, and 443 port,s which are the most common protocols needed for our server to work.

# ufw allow OpenSSH
# ufw allow 80,443
# ufw enable
# ufw status

With this, we have configured our firewall successfully

Step 4 – Change SSH port

By default, the SSH service works on port 22, and this is known to everyone. So, if a hacker wants, he can try hitting 22 port of your server. Hence, to add another layer of security, let’s change the port to something else. Since most of the services use ports from 1 to 1024, for the safest way, let’s use 2020, you can use any port between 10.24 and 65535. Follow the steps below to change the SSH port

Open the SSH configuration file

# nano /etc/ssh/sshd_config

Find the line

port 22

and make changes as shown below

#port 22
port 2020

Save the file by pressing “ctrl+x”, “y” and then “Enter”

Make sure to update the firewall as well by using the command given below.

# ufw allow 2020
# ufw reload
Note: change port as per your need

Now let’s restart the SSH service so the changes will take effect

# sudo systemctl restart sshd

Now, try connecting to your server using the new port. As explained in the steps above

Conclusion

With this, we have completed our initial server setup with Ubuntu. Now, the server is ready with the rest of the configuration.

Category: Servers Tagged In: server, ubuntu

Like my work? Don't Forget to Share

Share on Facebook Share on Twitter Share on LinkedIn Share on Reddit Share on WhatsApp Share via Email

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About Me

Hi, I am Sourabh. With over 12 years of experience in I.T, I make sure to publish genuine, easy and well tested tutorials. Hope you like my work. Thanks

SwiftGuides: How-to Guides, Tutorials & Much More · Copyright © 2025 · All Rights Reserved

  • Privacy Policy
  • Contact Us
  • Disclaimer