Logo

SSH Connection to a VPS

SSH Connection to a VPS

This guide walks you through, step by step, how to establish a secure SSH connection to a VPS from Linux, macOS, and Windows, and what to do immediately after your first login (security, updates, etc.).

Goals

  • Establish a reliable SSH connection to your VPS
  • Connect from Linux/macOS (Terminal) and Windows (PowerShell/PuTTY)
  • Perform the essential first-login tasks
  • Understand key-based authentication and common troubleshooting
  • Know recommended SSH/SFTP clients

Requirements

  • Public IP address of the VPS (provided by your host)
  • Login credentials (root user and initial password, unless an SSH key is already configured)
  • An SSH client:
    • Linux/macOS: built-in Terminal
    • Windows: PowerShell/Command Prompt (native OpenSSH) or a GUI client (PuTTY, MobaXterm)

1) Gather your connection details

You typically receive by email: the VPS IP address, the user (often root), a temporary password, and the SSH port (22 by default).
On first login you’ll be asked to validate the host fingerprint, then change the root password.


2) Connect based on your OS

Linux / macOS (Terminal)

Open a terminal and run:

ssh root@VPS_IP
  • Replace VPS_IP with the real address (e.g. 203.0.113.10).
  • On first connection, accept the fingerprint by answering yes.

Windows — Option A: PowerShell / CMD (Windows 10+)

Open PowerShell or Command Prompt, then:

ssh root@VPS_IP

Windows — Option B: PuTTY (GUI client)

  1. Launch PuTTY.
  2. In Host Name, enter the VPS IP (e.g. 203.0.113.10).
  3. Port: 22, Connection type: SSH.
  4. Click Open, then authenticate when prompted.

3) First login: essential tasks

Accept the server’s fingerprint

Typical first-connection message:

The authenticity of host '203.0.113.10' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Change the root password

passwd

Choose a strong password (long, unique, with letters, numbers, and symbols).

Update the system

Debian/Ubuntu:

apt update && apt upgrade -y

AlmaLinux/Rocky/Oracle:

dnf update -y

Key-based auth significantly improves security and removes password typing.

Generate a key on your local machine (client)

Linux/macOS:

ssh-keygen -t ed25519 -C "my-local-machine"

Windows with PowerShell (OpenSSH):

ssh-keygen -t ed25519 -C "my-windows-machine"

Copy the public key to the VPS

Automated method (Linux/macOS, Windows 11+ with OpenSSH):

ssh-copy-id root@VPS_IP

Manual method:

  1. Show your public key (id_ed25519.pub) and copy its contents.
  2. SSH into the VPS, then:
mkdir -p /root/.ssh
chmod 700 /root/.ssh
echo "PASTE_YOUR_PUBLIC_KEY_HERE" >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys

(Optional) Disable password auth and direct root login

Edit SSH config on the VPS, then reload the service:

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sed -i 's/^#\?PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config
sed -i 's/^#\?PermitRootLogin .*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config
systemctl reload ssh || systemctl reload sshd
  • Create an admin user with sudo before disabling direct root login.

5) Troubleshooting common issues

“Host key verification failed” (fingerprint changed)

Remove the old fingerprint from known_hosts, then try again:

ssh-keygen -R VPS_IP

Connection refused or timing out

Check the VPS firewall and open TCP/22 if needed:

ufw status
ufw allow 22/tcp

Also ensure the SSH service is running:

systemctl status ssh || systemctl status sshd

Wrong credentials / forgot password

Use your provider’s emergency console (noVNC/web console) to reset the password if necessary.

Root access disabled

Log in with an admin user, then become root:

sudo -i

GUI apps (with SFTP)

  • Windows: PuTTY, MobaXterm, WinSCP, FileZilla
  • macOS: FileZilla (SFTP) ; Terminal for SSH
  • Linux: FileZilla (SFTP) ; Terminal for SSH

Mobile apps

  • Termius (iOS/Android)

7) Next steps (security and services)

  • Harden your VPS (firewall, Fail2ban, hardened SSH)
  • Install Nginx + PHP-FPM (web hosting)
  • Install and secure MySQL/MariaDB
  • Set up backups and automatic updates

Frequently Asked Questions (FAQ)

Can I change the SSH port?
Yes. Edit the Port directive in the SSH config, open the new port on the firewall, reload SSH, then test in a second session before closing the original one.

How do I connect with SFTP to transfer files?
Use FileZilla or WinSCP. Host: VPS IP, Protocol: SFTP, Port: 22, SSH credentials.

Do I need to accept the fingerprint at every login?
No. You accept it only the first time. If it later changes without a clear reason, investigate before accepting.


Summary

  • Quick connection from Linux/macOS/Windows using the SSH client
  • Change the password and update the system on first login
  • Strongly recommended: key-based authentication
  • Handy commands to resolve common issues

Join our Discord community server

For any questions, suggestions, or just to chat with the community, join us on Discord!

900+Members