Skip to content

Tutorials Servers Intermediate1 min read

Connect to Your VPS with SSH and Secure It

Log in to a Linux VPS over SSH, create a sudo user, switch to key-based login, update packages and enable a firewall — the first steps for any new server.

By ZSOLNET Editorial Team Updated

Key takeaways

  • Log in as root once to create a regular user with sudo rights, then use that user day to day.
  • Use SSH keys instead of passwords and disable password login once keys work.
  • Keep the system updated and allow only the ports you actually use through the firewall.

A VPS is self-managed: the first job is to log in and lock it down. These commands are for Ubuntu or Debian; other distributions use similar steps with different package tools.

Step 1 — Connect for the first time

On macOS, Linux or Windows 10/11 (PowerShell or Terminal):

ssh root@203.0.113.10

Replace the address with your server’s IP. Accept the host fingerprint on first connection, then enter the root password.

Step 2 — Update the system

apt update && apt upgrade -y

Step 3 — Create a user with sudo rights

adduser deploy
usermod -aG sudo deploy

Step 4 — Set up SSH key login

On your own computer, create a key if you don’t have one, then copy it to the server:

ssh-keygen -t ed25519 -C "you@example.com"
ssh-copy-id deploy@203.0.113.10

Open a new terminal and confirm you can log in as deploy without a password before going further.

Step 5 — Disable root and password login

Edit the SSH configuration:

sudo nano /etc/ssh/sshd_config

Set these values:

PermitRootLogin no
PasswordAuthentication no

Then reload SSH, keeping your current session open until you’ve tested a new login:

sudo systemctl reload ssh

Step 6 — Turn on the firewall

sudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp
sudo ufw enable
sudo ufw status

Only open other ports when a service needs them.

Step 7 — Keep it updated

Enable automatic security updates:

sudo apt install unattended-upgrades -y
sudo dpkg-reconfigure --priority=low unattended-upgrades

Your server is now ready for a web server, database or application stack.

Frequently asked questions

Where do I find my server's IP and root password?

In the welcome email or the service details in your client area after the VPS is provisioned.

I locked myself out after changing SSH settings — what now?

Use the provider's console access (VNC) from the client area to log in directly and revert the change.

Share X LinkedIn Facebook

Log in to your account

Manage your domains, hosting and invoices in one place.

Secure connection straight to the ZSOLNET client area.

No account yet?