PricingFAQ
Log inSign Up

How to Create an SSH Key in Linux (Easy Step-by-Step Guide)

Tutorials

8 Aug 2025

How to Create an SSH Key in Linux (Easy Step-by-Step Guide)

How to Create an SSH Key in Linux: Easy Step-by-Step Guide

If you're using a VPS, the safest way to log in is not with a password — it's with SSH keys.

In this guide, you'll learn how to create an SSH key on Linux, and how to use it to securely access your VPS (for example, from nanohost.org, where VPS plans start at just $8/month).

No prior experience required.

What is an SSH Key?

An SSH key is a pair of files used to authenticate with a server. It consists of:

  • Private key — stored on your local machine (keep this secret!)
  • Public key — stored on the server

When you try to log in, your VPS checks the public key, and if it matches your private key, access is granted — no password needed.

Step 1: Generate the SSH Key Pair

Open your Terminal and run: ssh-keygen

You’ll see something like:

Image

Just press Enter to accept the default location.

➕ You’ll then be asked:

Enter passphrase (empty for no passphrase):

This is optional. If you want extra security, type a passphrase.

Otherwise, press Enter twice to skip.

🎉 Done! Your SSH key pair is now created.

Step 2: Check the Files

Your keys are saved in the ~/.ssh folder:

  • Private key: ~/.ssh/id_rsa
  • Public key: ~/.ssh/id_rsa.pub
Image

Never share your private key!

Step 3: Upload the Public Key to Your VPS

Assuming your VPS IP is 45.12.34.56 and your username is root:

ssh-copy-id root@45.12.34.56

You’ll be asked to enter your VPS password once. After that, your key will be uploaded.


Don’t have ssh-copy-id? Use this:

cat ~/.ssh/id_rsa.pub | ssh root@45.12.34.56 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

 

Step 4: Log In Using Your Key

Now try logging in:

ssh root@45.12.34.56

If everything worked, you’ll be logged in without a password!

Disable Password Login (Optional but Recommended)

To force key-only logins, edit the SSH config on your server: nano /etc/ssh/sshd_config

Find or add these lines:

PasswordAuthentication no PermitRootLogin prohibit-password


Then restart SSH:

systemctl restart ssh


⚠️ Only do this if you're sure your key works! Otherwise, you may lock yourself out.

🌍 Get a VPS with SSH Access Ready

Looking to set up your own server?

At nanohost.org, you get:

  • ⚡ Fast and reliable VPS
  • 🌐 Global locations
  • 🔐 SSH access pre-configured
  • 💸 Starting at just $8/month

Perfect for running proxies, apps, or learning Linux.

how-tolinuxbasics

Read also

How to Create an SSH Key in Linux (Easy Step-by-Step Guide)

How to Create an SSH Key in Linux (Easy Step-by-Step Guide)

Tutorials

Secure your server the right way! Learn how to generate and use SSH keys on Linux — a simple step-by-step guide for beginners.

How to Connect to a VPS Server via SSH (Step-by-Step)

How to Connect to a VPS Server via SSH (Step-by-Step)

Tutorials

New to VPS hosting? Learn how to connect to your server via SSH in under 5 minutes — step-by-step for beginners.

Creating a SOCKS5 Proxy Using Own VPS

Creating a SOCKS5 Proxy Using Own VPS

Tutorials

Need more privacy online or want to access content from another region? A SOCKS5 proxy is a simple way to route your internet traffic through a remote server. In this guide, we’ll show you how to create your own SOCKS5 proxy using a VPS and Docker — even if you’re not a technical expert.

Products

Server in the United StatesServer in the United KingdomServer in NetherlandsServer in SingaporeServer in Poland

NOVPS CLOUD LTD ©2025