# VPS servers

# Basic server configuration for VPS - Debian/Ubuntu

## Creating a New User

```bash
adduser username

```

## Add the user to the sudo group (so they can run administrator commands):

```bash
usermod -aG sudo username

```

## Disabling Root Login via SSH and changing the SSH Port

1. Edit the SSH configuration file:

```bash
nano /etc/ssh/sshd_config

```

2. Find the line:

```bash
PermitRootLogin yes

```

3. Change it to:

```bash
PermitRootLogin no

```

4. Save the file and restart SSH:

```bash
sudo systemctl restart ssh

```

5. In the same file:

```bash
sudo nano /etc/ssh/sshd_config

```

6. Find or add the line:

```bash
Port 2222

```

**Note:** Replace 2222 with any port you want to use.

7. Restart SSH:

```bash
sudo systemctl restart ssh

```

**Note:** After changing the port, connect using:

```bash
ssh -p 2222 username@server_ip

```

## Installing UFW and basic firewall configuration

1. Install UFW:

```bash
sudo apt update
sudo apt install ufw -y

```

2. Allow your new SSH port (e.g., 2222):

```bash
sudo ufw allow 2222/tcp

```

3. If you’re still using the default port 22:

```bash
sudo ufw allow 22/tcp

```

4. Set default policies

```bash
sudo ufw default deny incoming
sudo ufw default allow outgoing

```

5. Allow HTTP and HTTPS:

```bash
sudo ufw allow 80/tcp #http
sudo ufw allow 443/tcp #https

```

7. Enable the firewall:

```bash
sudo ufw enable

```

8. Check the status:

```bash
sudo ufw status verbose

```