---
title: VPS Setup Manual
description: A cheat sheet for remote VPS setup: just a set of steps and commands to keep close for the next time I need to set it up manually.
tokens: ~580
---

# VPS Setup Manual

This note contains basic instructions for a fresh Ubuntu server (Ubuntu 24.04 at the time of writing), a set of steps and commands to keep close for the next time I need to set it up manually.

## Connect to the VPS

Connect to the server as root using SSH:

```bash
ssh root@ip     # replace ip with the server IP address
```

## Package maintenance

```bash
apt update      # update the package list
apt upgrade -y  # update installed packages

reboot          
shutdown -r now # reboot now
shutdown -h now # shutdown now
shutdown -h +10 # shutdown in 10 minutes
shutdown -c # cancel a scheduled shutdown
```

## Create a new user

In order not to use the root user for everyday server work, we need to create a new user and give them super user rights.

```bash
adduser normal_user               # add new user
usermod -aG sudo normal_user      # add the user to the sudo group

su - normal_user                  # switch to a new user
sudo whoami                       # check sudo access

exit
```

## Enable SSH login for the new user

```bash
mkdir -p ~/.ssh                   # create .ssh directory for the new user                 
vi ~/.ssh/authorized_keys         # paste your public key

sudo ssh normal_user@ip           # login with the new user
chmod 644 ~/.ssh/authorized_keys  # change file permission
```

Once key login works, to disable root login, edit **`/etc/ssh/sshd_config`** (as root):

```text
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
```

Apply changes safely:

```bash
sudo sshd -t
sudo systemctl restart ssh
```


Test that the new user still works:

```bash
ssh normal_user@ip
```

Then check that root login is disabled:

```bash
ssh root@ip
```

## Auth log

Ubuntu writes SSH logins, PAM sessions, and many `sudo` events to `/var/log/auth.log`.

```bash
sudo cat /var/log/auth.log
sudo tail -f /var/log/auth.log
```

## Install `zsh`

```bash
sudo apt install zsh    # install zsh
chsh -s $(which zsh)    # set it as the default shell
vi ~/.zshrc             # customize the config
source ~/.zshrc         # apply the changes
```

### Ghostty backspace/backslash quick fix

If some keys behave incorrectly in Ghostty on the VPS, it might help to set the terminal type manually.

Add this to `~/.zshrc` on the VPS:

```bash
export TERM=xterm-256color
```