How to Connect to Your VPS via SSH for the First Time

Connecting to your VPS for the first time feels like opening the hood of your own car in the garage: everything is under your control, and you get to decide how the engine is tuned. SSH (Secure Shell) is the tool that makes that possible. It gives you an encrypted terminal session to your server, from anywhere in the world.

If you just bought a VPS and received an email with an IP address, a username, and a password (or a private key file), this guide takes you from that email to a working SSH session in about ten minutes. No prior server experience needed.

What You Need Before You Start

Your hosting provider normally sends these details right after the VPS is provisioned. Gather them before opening a terminal:

  • Server IP address — something like 203.0.113.45. This is your server’s public address.
  • Username — usually root or ubuntu, depending on the provider and OS image.
  • Password or SSH private key — either a root password, or a .pem key file the provider asks you to download.
  • A terminal — macOS and Linux ship with one. Windows 10 and 11 ship with OpenSSH built into Windows Terminal and PowerShell.

SSH listens on port 22 by default. If your provider uses a custom port, they will tell you — and you will add it with -p, as shown below.

Connecting from Linux and macOS

Open your terminal and type:

ssh username@server-ip

For example, if your username is ubuntu and your IP is 203.0.113.45:

ssh [email protected]

The first time you connect, you will see a host key fingerprint warning:

The authenticity of host '203.0.113.45' can't be established.
Are you sure you want to continue connecting (yes/no)?

This is normal on a first connection — your computer is confirming that it has never seen this server before. Type yes and press Enter. Then enter your password when prompted. Type it carefully: nothing appears on screen while you type, which is expected behavior, not a bug.

If your provider gave you a .pem key file instead of a password, first restrict its permissions, then pass it with -i:

chmod 400 ~/Downloads/my-key.pem
ssh -i ~/Downloads/my-key.pem [email protected]

And if the provider assigned a custom port, add -p:

ssh -p 2222 [email protected]

Connecting from Windows

Since Windows 10 version 1809, OpenSSH is built in. Open Windows Terminal or PowerShell and use the same command:

ssh [email protected]

If you get “ssh is not recognized,” OpenSSH is probably not enabled. Fix it in Settings > Apps > Optional features, add OpenSSH Client, and restart your terminal. Alternatively, install Windows Terminal from the Microsoft Store — it includes OpenSSH and tabbed sessions out of the box.

Some people still prefer PuTTY, especially when they need saved sessions. If you go that route: enter the IP in the Host Name field, keep port 22, click Open, then log in as your username. PuTTY does not natively read .pem files — convert them with PuTTYgen to .ppk format first, under Connection > SSH > Auth in the session settings.

Switching to SSH Key Authentication

Passwords work, but SSH keys are safer and more convenient. Bots constantly scan the internet trying common passwords on port 22, so moving to keys is the single biggest security upgrade a new VPS owner can make. Here is the practical flow:

  1. Generate a key pair on your own computer (not on the server):
    ssh-keygen -t ed25519 -C "[email protected]"
    

    Press Enter to accept the default file location. A passphrase adds a second layer of protection; it is optional but recommended.

  2. Copy the public key to your server:
    ssh-copy-id [email protected]
    

    Enter your password one last time. If ssh-copy-id is unavailable (Windows), copy the contents of ~/.ssh/id_ed25519.pub manually and paste it into ~/.ssh/authorized_keys on the server.

  3. Test key-only login by opening a new session. If it works without asking for a password, you can disable password authentication. Edit /etc/ssh/sshd_config on the server, set PasswordAuthentication no, then restart SSH:
    sudo systemctl restart sshd
    

    Keep your first session open until the new login is verified — if something is misconfigured, you still have a working terminal to fix it.

What to Do Right After Your First Login

Before installing anything else, spend five minutes on these basics. They save real pain later:

  • Update the system: on Ubuntu/Debian run sudo apt update && sudo apt upgrade -y. On RHEL-based systems use sudo dnf upgrade -y.
  • Check who you are: whoami and hostnamectl confirm your user and machine. Make sure you landed on the right server.
  • Create a non-root user with sudo rights and use it for daily work instead of root:
    adduser admin
    usermod -aG sudo admin
    
  • Enable a firewall — sudo ufw allow OpenSSH && sudo ufw enable on Ubuntu keeps every port except SSH closed by default.
  • Note your public IP and access details somewhere safe, outside the server itself.

Common Connection Errors and Fixes

Error What it means Fix
Permission denied (publickey,password) Wrong username, password, or key Check the provider’s welcome email; confirm the username; verify the key file path and permissions (400)
Connection refused Nothing listening, or wrong port Confirm the port (default 22), check the provider’s console for firewall rules
Connection timed out Network blocked or server unreachable Check your local network/VPN, the provider’s firewall, and whether the VPS finished booting
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED Host key differs from your first visit Expected after reinstalling the OS; remove the old key with ssh-keygen -R 203.0.113.45 and reconnect. If you did not reinstall, ask your provider before trusting the new key.
UNPROTECTED PRIVATE KEY FILE Key file readable by others Run chmod 400 key.pem and retry

Takeaways

Your first SSH session is a rite of passage: open a terminal, run ssh username@server-ip, accept the host key, and you are in. From there, switch to SSH key authentication, disable password logins, create a non-root user, and turn on the firewall. That handful of steps takes under twenty minutes and removes most of the common attack surface on a fresh VPS.

Once you are comfortable connecting, the natural next steps are deploying your first web server and hardening SSH further — topics covered in later tutorials on this site.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.