Initial Setup Guide for Ubuntu 22.04 on a VPS

Updated: 2024-06-02
1 min read
[Linux Ubuntu]

Update and Upgrade Packages

apt update
apt upgrade -y

Setting Up SSH Keys

Using SSH keys instead of passwords enhances security. First, generate an SSH key pair on your local machine (if you don’t already have one):

ssh-keygen -t ed25519 -C "your_email@example.com"

Next, copy your public SSH key to the new user’s account on your server. You can do this from your local machine:

ssh-copy-id username@your_server_ip

# or with provided port
ssh-copy-id -p 1234 username@your_server_ip

This command uploads your public SSH key and configures the server to recognize it.

Disabling Password Authentication

To prevent SSH login using a username and password, edit the SSH configuration file:

sudo nano /etc/ssh/sshd_config

Find the following lines and modify them as shown:

PasswordAuthentication no
UsePAM no

After making these changes, restart the SSH service to apply them:

sudo systemctl restart sshd
Previous blast.io