---
title: First Server Setup with Ubuntu
description: "When you create a new Ubuntu server, performing a few essential configuration steps is crucial for both security and usability. These steps will enhance your server's protection and give you a stable foundation for deploying and managing applications effectively. ##…"
url: "https://truehost.com/support/knowledge-base/first-server-setup-with-ubuntu/"
updated: "2024-10-18"
category: Cloud servers in Kenya
---

# First Server Setup with Ubuntu

When you create a new Ubuntu server, performing a few essential configuration steps is crucial for both security and usability. These steps will enhance your server's protection and give you a stable foundation for deploying and managing applications effectively.

## **Prerequisites**

- A server with Ubuntu Installed. We will use Ubuntu 22.04 here.
- Root SSH access to the server

Below are the steps that we will go through in this article;

1. **Logging in as root**
2. **Creating a New User**
3. **Granting Administrative Privileges**
4. **Setting Up a Firewall**
5. **Enabling External Access for Your Regular User**

---

### **Step 1 — Logging in as Root**

To begin, you need to SSH into your server using as root. Please see **[these steps](https://truehost.com/support/knowledge-base/how-to-access-a-server-via-ssh-terminal/)** on how to

**About the Root User:** The root account has full administrative privileges, making it a powerful but potentially risky account to use regularly. To avoid accidental damage, it’s better to create a new user account with fewer privileges for daily use. We will create a user called **tke**

---

### **Step 2 — Creating a New User**

Once logged in as root, you can create a new user for regular use. In this case, replace `tke` with your desired username:

```
adduser tke
```

![](https://truehost.com/support/wp-content/uploads/2024/10/image-408.png)

You will be asked to set a password for the new user, and optionally, you can fill in other user information. You can skip any fields by pressing ENTER.

---

### **Step 3 — Granting Administrative Privileges**

Next, grant administrative privileges to your new user by adding them to the `sudo` group, which allows the user to run commands with elevated privileges using the `sudo` command.

Run the following command to add your new user (replace `tke` with your username):

```
usermod -aG sudo tke
```

Now, your new user can execute administrative tasks by prefixing commands with `sudo`.

---

### **Step 4 — Setting Up a Firewall**

Ubuntu includes a firewall tool called UFW (Uncomplicated Firewall), which you can use to block unwanted traffic and allow access to necessary services.

Check which applications are available for firewall configuration by typing:

```
ufw app list
```

The output should show that **OpenSSH** is listed, which is essential for maintaining SSH access.

![](https://truehost.com/support/wp-content/uploads/2024/10/image-409.png)

Allow SSH connections through the firewall by typing:

```
ufw allow OpenSSH
```

Now enable the firewall:

```
ufw enable
```

You can verify the firewall status with:

```
ufw status
```

The firewall will now allow SSH connections while blocking other types of connections by default.

![](https://truehost.com/support/wp-content/uploads/2024/10/image-410.png)

---

### Step 5 — Enabling External Access for Your Regular User

Now that your regular user is set up, you need to ensure that you can log in using that account. Depending on whether your root account uses a password or SSH key, follow one of the steps below:

**If the root Account Uses Password Authentication:**

You can now log in as your new user by opening another terminal session and using:

```
tke@your_server_ip
```

After entering your password, you will be logged in as your regular user.

![](https://truehost.com/support/wp-content/uploads/2024/10/image-411.png)

![](https://truehost.com/support/wp-content/uploads/2024/10/image-412.png)

**If the root Account Uses SSH Key Authentication:**

You can optionally set up SSH keys for your server using **[these steps](https://truehost.com/support/knowledge-base/how-to-configure-ssh-key-for-a-user/)**

If you logged in as root using SSH keys, you need to copy your SSH key to the new user’s account. Use the following command to transfer the SSH configuration to the new user (make sure to replace `tke`):

```
rsync --archive --chown=tke:tke ~/.ssh /home/tke
```

Now, open a new terminal session and log in using SSH:

```
ssh tke@your_server_ip
```

You should be logged in without entering a password.

---

By following these steps, you've created a secure and well-configured Ubuntu server that's ready for further development or deployment tasks.
