Linux

How to connect to a Linux VPS for the first time via SSH

The first thing you should do with a new VPS

You just rented your first Linux VPS. The control panel shows it's running, but you can't see it, there's no monitor, no keyboard, no mouse. The only way in is through a secure shell protocol: SSH. Connecting to a Linux VPS via SSH for the first time is the fundamental skill every sysadmin learns. Without it, you cannot install software, harden security, or deploy anything. This guide assumes you have a Linux VPS (Ubuntu 24.04 or Debian 12) with root access, and a computer running Windows, macOS, or Linux. By the end, you'll be logged into your VPS with a verified, secure connection.

Prerequisites

  • A Linux VPS (Ubuntu 24.04 LTS, Debian 12, AlmaLinux 9) with root/Administrator access, this guide works for any Linux VPS with KVM virtualization.
  • The VPS must be powered on and reachable. If you just ordered one from a provider like thueVPS, you usually receive the root password and IPv4 address within minutes after payment.
  • An SSH client installed on your local machine: on Linux/macOS it's built in, on Windows you can use PowerShell, Windows Terminal, or download PuTTY.
  • Basic familiarity with your computer's terminal or command prompt.

No domain, no DNS, we connect by IP address directly. If you opted for a VPS Vietnam with dedicated IPv4, your provider gives you a public IP right away.

The two ways to authenticate via SSH

SSH supports two main authentication methods: password and public-key. For a first connection, most VPS providers give you a temporary root password by default. However, the best practice, and what we'll do here, is to generate an SSH key pair before connecting. The key pair consists of a private key (kept secret on your machine) and a public key (placed on the VPS). Using key authentication is more secure than passwords because the key is cryptographically strong and cannot be brute-forced. If your provider gave you a raw password, you can still log in once to install your key, then disable password login permanently. For this guide, we assume you have either the root password or the ability to add your public key through the provider's control panel.

Step 1, Get your VPS IP address and credentials

Your VPS provider (whether it's thueVPS, DigitalOcean, or Hetzner) will send you a welcome email containing: the IPv4 address of your VPS, the root password or a one-time password, and instructions on how to log in. Keep this information safe. If you lose it, you can typically find the IP and password by logging into the provider's control panel. Some providers also let you paste an SSH public key during the ordering process, if you did that, skip to Step 3.

Example welcome data:
IP: 103.xxx.xxx.xx
Username: root
Password: tempRootPass123!
SSH Port: 22

Write down the IP address. If your VPS is behind a NAT or uses a different port (e.g., a provider may configure SSH on port 2222), note that as well. The default port for SSH is 22.

Step 2, Generate an SSH key pair (recommended)

Before you make your first connection, generate a secure key pair. Open your local terminal (on Linux/macOS) or PowerShell (on Windows).

ssh-keygen -t ed25519 -C "[email protected]"
  • The -t ed25519 flag selects the Ed25519 algorithm (faster and more secure than RSA). If your client doesn't support Ed25519 (very old systems), use -t rsa -b 4096 instead.
  • The -C flag adds a comment (usually your email) so you know which key belongs to which machine.
  • You will be prompted: Enter file in which to save the key. Press Enter to accept the default (~/.ssh/id_ed25519).
  • Then it asks for a passphrase. You can leave it empty for convenience, but adding a passphrase protects your private key if it ever gets stolen.

After the command runs, you'll see output like:

Your identification has been saved in /home/you/.ssh/id_ed25519
Your public key has been saved in /home/you/.ssh/id_ed25519.pub

Now you have two files: id_ed25519 (private, never share) and id_ed25519.pub (public, safe to share). View your public key with:

cat ~/.ssh/id_ed25519.pub

Copy the output, you will need it to log in without a password.

Spec table: SSH key algorithm comparison

Key typeBit lengthSecurity levelSpeedRecommended?
RSA2048 or 4096GoodSlowerOnly if compatibility
Ed25519256ExcellentFastYes (default)
ECDSA256/384/521GoodVery fastCaution (non-standard)

Step 3, Connect to your Linux VPS via SSH (Windows with PuTTY)

If you're on Windows and prefer a graphical SSH client, download and install PuTTY from the official website (putty.org). Launch PuTTY and do the following:

  • In the Host Name field, enter the IP address of your VPS (e.g., 103.xxx.xxx.xx).
  • Ensure the Port is 22 (or whatever port your provider uses).
  • Under Connection → SSH → Auth → Credentials, click Browse and select your private key file (id_ed25519.ppk, if you generated with PuTTY's keygen, or convert with PuTTYgen). If you use password auth, skip the key section.
  • Click Open. The first time you connect to a new server, PuTTY will show a security alert: "The server's host key is not cached in the registry." This is normal. Click Accept to store the host key.
  • A terminal window appears asking for your username. Type root and press Enter. If using a key, it should log in automatically. If using a password, type the root password (you won't see characters for security) and press Enter.

Verify: You should see a command prompt like root@your-vps:~#. Congratulations, you are now connected to your Linux VPS!

Step 3 (alternative), Connect from Linux/macOS terminal

On Linux or macOS, you have a native SSH client. Open a terminal window and type:

ssh -i ~/.ssh/id_ed25519 [email protected]

Replace 103.xxx.xxx.xx with your VPS IP. The -i flag points to your private key. If you haven't set up a key on the VPS yet and are using a password instead, omit the -i flag:

ssh [email protected]

You'll be prompted to enter the root password. The first time you connect, you'll also see a fingerprint prompt:

The authenticity of host '103.xxx.xxx.xx (103.xxx.xxx.xx)' can't be established.
ED25519 key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)?

Type yes and press Enter. This adds the host to your ~/.ssh/known_hosts file, it's a security measure to prevent man-in-the-middle attacks.

Verify: After authentication, you should see the server's command prompt. Run a quick check:

hostname
ip addr show

The first command prints your VPS hostname. The second shows network interfaces, look for your public IP. If both work, you're connected properly.

Step 4, Verify the SSH connection is working correctly

Do not assume that a successful login means everything is fine. Run these verification steps to confirm the connection is stable and secure:

  • Check uptime and system info: uptime, shows how long the VPS has been running. Should show minutes/hours, not "0".
  • Check SSH version: ssh -V from your local machine, output should show OpenSSH_9.x or later. On the server, run sshd -V or check ssh -Q.
  • Test file transfer with SCP: From your local terminal, try copying a small file to the VPS:
scp ~/test.txt [email protected]:/root/

If no error, the connection supports data transfer correctly.

  • Check host key fingerprint: On the VPS, run ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub. Compare this fingerprint with what your local machine cached in ~/.ssh/known_hosts. They must match.

Troubleshooting common SSH connection issues

Connection timed out, The VPS may not be reachable. Verify the IP is correct and the VPS is running (check your provider's control panel). Some VPS pricing plans include an optional firewall, make sure port 22 is open.

Connection refused, SSH server is not running on the VPS. If you have console access via the provider's panel (e.g., VNC/HTML5 console), log in and run systemctl status ssh and systemctl start ssh.

Permission denied (publickey), The key on the VPS doesn't match your private key. Double-check you pasted the correct public key into ~/.ssh/authorized_keys on the VPS. You can also copy it after logging in with a password: echo "your-public-key-string" >> ~/.ssh/authorized_keys.

Host key verification failed, The server fingerprint changed (common after OS reinstall). Run ssh-keygen -R 103.xxx.xxx.xx on your local machine to remove the old fingerprint, then try connecting again.

Password auth not working, Some VPS images (Debian 12 VPS for example) ship with password authentication disabled by default. You must use a key or re-enable password auth via the console.

FAQ

What is SSH and why do I need it to connect to my VPS?

SSH (Secure Shell) is an encrypted network protocol that lets you securely log into a remote server over an untrusted network like the internet. Without SSH, you have no way to manage your Linux VPS from your local computer.

Can I use a password instead of an SSH key?

Yes, but it is less secure. Passwords can be guessed or brute-forced. SSH keys are much stronger and recommended for any production VPS. Many providers now allow key-only connections.

Which OS should my local machine run to connect to a VPS?

Any OS works: Windows (using PuTTY, PowerShell, or Windows Terminal), macOS (native terminal), or Linux (native terminal). The process is similar across all platforms.

What port does SSH use by default?

Port 22. Some providers or advanced users change it to a non-standard port (e.g., 2222, 9922) to reduce automated attacks. Always verify the port in your welcome email or control panel.

How do I copy a file from my local machine to the VPS over SSH?

Use SCP: scp /local/file root@YOUR_VPS_IP:/remote/directory/. Or use rsync for larger transfers.

What if I lose my private key?

If you lose the private key and have not set up an alternative method, you will be locked out. Always keep a backup of your private key file in a safe place. Most VPS providers offer console access through the control panel as a rescue method.

Related articles

Note: This guide is for general reference. Every system and infrastructure has its own specifics, so test each step in a safe environment and consult a qualified engineer before applying it in production.