To connect via SSH to a VPS with a key, open a shell and run ssh -i /path/to/private_key username@server_ip. The matching public key must already be installed for that account.

SSH, short for Secure Shell, gives you encrypted shell access to the host. We recommend key-based access because it avoids sending an account password during login.

Have your key ready? Let's get your login details in place, choose your client, and get you logged in.

Key takeaways before connecting

  • Keep your private key on your computer. The matching public key belongs on the remote host.
  • SSH uses port 22 by default. A custom port needs the -p option.
  • Your key passphrase and account login credential are separate.
  • Keep a working session open while changing access settings, so you have a way back in.

Gather your VPS connection details

A successful login starts with the right details. We suggest keeping them together in your credential manager, without sharing your private key.

Find the address, account, and port

You'll need the host's public IP address, SSH username, and port. The username is often root, but some Linux images use a separate administrator account with sudo permissions.

Root has unrestricted administrative access. A sudo-enabled account lets you run administrative commands when needed, without working as root throughout the session.

Use this syntax: ssh username@server_ip. For a remote system configured for root access, use ssh root@YOUR_VPS_IP.

Replace the placeholders with your actual details. The default SSH port is 22.

Have the correct credential ready

For key-based access, you'll need your private key file and its passphrase, if you set one. The server needs the matching public key under the account you're accessing.

For password-based access, you'll need that account's password. Keep it available for initial access or recovery if your host permits password login.

A key installed for one user doesn't automatically authorize another.

Open an SSH client on your computer

The syntax is almost identical across operating systems. The main difference is where you type it.

An open laptop with a blurry terminal screen sits on a wooden table next to a notepad and a coffee cup.

Windows: PowerShell, Windows Terminal, or PuTTY

Open PowerShell directly, or launch a PowerShell tab in Windows Terminal. Type ssh to see whether the OpenSSH client is available. If Windows doesn't recognize it, add the OpenSSH Client through Optional Features.

Prefer PuTTY? Enter your VPS IP address in Host Name, enter the SSH port, select SSH, and click Open.

For key authentication in PuTTY, select your private key under Connection, SSH, Auth, Credentials before opening the connection. PuTTY commonly uses .ppk files; PuTTYgen can convert an existing OpenSSH private key.

macOS: Terminal from Spotlight

Press Command-Space, search for Terminal, and open it. You can run the examples below directly.

The built-in client handles ordinary VPS access without another application. Your local username doesn't need to match your VPS username because you specify the remote account in the command.

Linux: Your usual terminal

Open your distribution's shell app. Major Linux distributions commonly include the SSH client, though minimal installations may require the OpenSSH client package.

Commands run here begin on your computer. After login, commands run on the VPS instead. That distinction matters when you edit files or restart services.

Connect with your existing SSH key

Your private key proves you're authorized to access an account. It stays on your computer when you connect to a remote host.

Select the private key file

Use this syntax:

ssh -i /path/to/private_key username@host_ip

For an existing key named id_ed25519 in the usual location, macOS and Linux users can run:

ssh -i ~/.ssh/id_ed25519 username@host_ip

In Windows PowerShell, use:

ssh -i "$HOME\.ssh\id_ed25519" username@host_ip

Use your actual private key filename. Don't select its .pub companion, which is the public key.

Ubuntu's OpenSSH keys guide explains how the two files work together. Only the .pub file goes on the remote account. Sharing the private key gives away your login credential.

You can use an existing key pair or generate an Ed25519 pair on macOS, Linux, or Windows PowerShell:

ssh-keygen -t ed25519 -C "your_email@example.com"

On macOS or Linux, install the public key with:

ssh-copy-id -i ~/.ssh/id_ed25519.pub username@host_ip

In PowerShell, open the .pub file, copy its contents, then add them to the account's ~/.ssh/authorized_keys file using the provider console. If the matching public key isn't installed for your account, selecting a local private key won't grant access.

On macOS or Linux, set the local key permissions with:

chmod 700 ~/.ssh && chmod 600 ~/.ssh/id_ed25519

In Windows PowerShell, restrict access to the private key with:

icacls "$HOME\.ssh\id_ed25519" /inheritance:r /grant:r "$($env:USERNAME):(R)"

On the remote account, set the SSH directory and public key file permissions with:

chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys

Add a custom SSH port

If your server uses another port, use this syntax:

ssh -p PORT username@host_ip

To combine a custom port with a specific key, run:

ssh -i /path/to/private_key -p PORT username@host_ip

Replace PORT with the configured SSH port number. The lowercase options matter: -p selects the port, while -i selects the identity file.

The OpenSSH client manual documents these options. Keep the first login simple and leave out settings you don't need.

Handle the first connection prompts

Your first login can show several prompts. Each has a different purpose, so take them one at a time.

Accept the expected server identity

The client may say that the host's authenticity can't be established, followed by a fingerprint and an option to continue.

That fingerprint identifies the host's SSH key. It concerns the host's identity, not your personal login key.

For an expected first login to a trusted host, type yes to accept the host key. Acceptance records the identity for future logins; typing yes alone doesn't prove that the host is genuine.

An unexpected changed-host warning deserves attention. Don't treat it as the ordinary first-login prompt.

Enter the right password or passphrase

A prompt saying Enter passphrase for key wants the passphrase protecting your local private key.

A prompt such as username@server_ip's password wants the remote account credential. If you expected key-only access, that credential prompt can mean the key wasn't accepted.

Nothing appears while you type, including dots or asterisks. That's normal. Enter the credential and press Enter.

After login, you'll see a remote shell prompt, often with the username and host name. Run whoami to see the active account. Type exit when you're finished.

Use the browser console when local access fails

A provider's browser console gives you another route into the machine. We recommend keeping it available before changing SSH or network settings.

Hostinger's Web Console opens a browser session and logs you in automatically. If a password prompt appears inside the console, typed characters remain invisible there too.

Credential delivery varies by provider. Elypse describes sending the initial password by email when an order is placed. Hostinger doesn't display an existing root password; its Root password option lets you create a replacement.

For Hostinger recovery, the available dashboard actions include restoring default firewall rules under Settings and resetting SSH through the SSH configuration menu. The browser terminal also helps establish whether the server is running.

Use configuration resets carefully. Restoring those defaults can affect access rules for other services. A browser console is useful recovery access, but it doesn't replace a tested local SSH connection.

Troubleshoot SSH connection errors

The error message usually tells you which part needs attention. Start there instead of changing several settings at once.

A row of server racks in a data center with one open mesh door.

Connection refused

This usually means something actively rejected the attempt. Common causes include an SSH service that isn't running or a client using the wrong port.

Confirm the VPS is powered on and the IP address is correct. Use the browser console to inspect SSH. Depending on the distribution, its service is commonly named ssh or sshd.

A custom SSH port needs the same value in your local -p option.

Connection timed out

A timeout usually points to an unreachable address, blocked traffic, or an unavailable host.

Check the VPS power status, public IP, provider firewall, and Linux firewall. If SSH uses its default port, allow inbound TCP port 22. If it uses a custom port, allow that port instead.

Provider-level rules and operating-system rules both matter. Opening only one layer won't fix a block in the other.

Permission denied

The server was reached, but authentication failed. Recheck the username, selected private key, and account credential if password authentication is enabled.

Permission denied (publickey) means the offered key wasn't accepted. Check that the matching public key is in the correct account's authorized_keys file. Also check that the local private key and remote .ssh permissions are restrictive.

For more detail, run ssh -v -i /path/to/private_key username@server_ip. The diagnostic output shows authentication attempts. Remove sensitive details before sharing it.

Keep access secure after the first login

The first login is only the start. Keeping access dependable is the next job.

We recommend a separate sudo-enabled administrator account for routine work. Test its key-based login in a second terminal before disabling password authentication or direct root login.

Keep the original working session open until the new login succeeds. An untested configuration change can lock out your next connection.

Limit exposed ports to services you use. Remove unused accounts and retired keys when people leave. Keep the operating system and installed services updated.

Our guide to self-managed VPS responsibilities covers the maintenance that comes with root access.

Still choosing your server? Our VPS website hosting options include Linux configurations with a control panel or without one. Choose a panel for convenient website administration, or a no-panel setup when direct administrative control fits your workload.

Frequently asked questions

Does a key passphrase need entering every time?

Not necessarily. An SSH agent can hold an unlocked key for reuse, so you don't repeatedly enter its passphrase.

The OpenSSH ssh-add documentation explains how keys are added to a running agent. On a shared computer, avoid leaving an unlocked key available to another user.

Can SSH work alongside cPanel or Plesk?

Yes. A control panel handles common hosting tasks, while authorized SSH access provides shell administration.

The account permissions still determine what you can do. Our cPanel and Plesk comparison helps you choose the interface that fits your websites and management needs.

Make the next login straightforward

To connect via SSH, you need the right account, private key, and open network path. Once those match, you can connect using a saved command to access your VPS.

We recommend saving that command and testing a second login before tightening access settings. You'll have direct server control, plus a working way back in.

We use cookies so you can have a great experience on our website. View more
Cookies settings
Accept
Decline
Privacy & Cookie policy
Privacy & Cookies policy
Cookie name Active

Who we are

Our website address is: https://zadic.net.

Comments

When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection. An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download and extract any location data from images on the website.

Cookies

If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year. If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser. When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed. If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website. These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue. For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where your data is sent

Visitor comments may be checked through an automated spam detection service.
Save settings
Cookies settings