Connect to a VPS from Scratch: SSH Login and Basic Hardening
A practical guide for first SSH login, creating a non-root user, disabling password login, and keeping common troubleshooting commands close at hand.
This article is the written companion to the video tutorial. Watch the video for context, then use this page to copy commands and follow the checklist.
Before You Start
- An active VPS
- The server public IP address
- A local terminal
- The initial root password or SSH private key
Before changing SSH settings, make sure your provider offers a rescue console. It gives you a recovery path if a configuration mistake locks you out.
First Login
Replace the IP below with your server address:
ssh root@203.0.113.10
The first connection asks whether you trust the server fingerprint. If the IP is correct, type yes.
Create a Non-Root User
Avoid using root for daily work. Create a regular user and add it to the sudo group:
adduser quokka
usermod -aG sudo quokka
Switch to the new user and test sudo:
su - quokka
sudo whoami
If it prints root, sudo is working.
Disable Password Login
Add your public key to the server:
mkdir -p ~/.ssh
nano ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Then edit the SSH configuration:
sudo nano /etc/ssh/sshd_config
Confirm these settings:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
Keep the current terminal window open. Start a second terminal and test the new login before closing anything.
sudo systemctl restart ssh
ssh quokka@203.0.113.10
Common Issues
| Issue | What to Check |
|---|---|
| Connection timeout | Firewall, security group, incorrect IP |
| Permission denied | Public key content and file permissions |
| sudo unavailable | Whether the user is in the sudo group |