• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero® Blog

NameHero® Blog

Web Hosting Tips & Resources From NameHero

  • AI Agents
    • OpenClaw
    • Claude Code
    • n8n
    • Hermes Agent
    • Open WebUI
    • Docker
  • Hosting
    • Web Hosting
    • WordPress Hosting
    • WooCommerce Hosting
    • Enterprise Hosting
    • Email Hosting
    • HeroicGuard
    • GPU Hosting
    • Website Builder
  • VPS
    • Managed VPS
    • Unmanaged VPS
    • Flex VPS
  • Reseller
  • Gaming
  • Domains
  • Account
  • Blog Home
  • Categories
  • Authors

Using SSH Keys to Login to Your VPS – Part II

Bhagwad Park

Published on: June 29, 2020

Categories: VPS Hosting 0

In part I of this series, I explained how to generate a private/public key pair and upload the public key onto your server. Now we need to configure everything to make it work.

Step 1: Paste the Public Key into “authorized_keys”

The “authorized_keys” file contains all the public keys that we trust. In part I, we had a file called “public_rsa” in our /root/.ssh folder like this:

Public RSA Key Uploaded
Public RSA Key Uploaded

To insert this into authorized_keys, we just use the following command:

cat public_rsa >> ~/.ssh/authorized_keys

And we’re done!

Step 2: Configure PuTTY to Use our Private Key

As of now, we can still log into SSH via passwords. So we need to tell PuTTY to send our private key to the server instead of making the server prompt us for a password. To do this, open your PuTTY connection settings, then on the left-hand side, go to Connection->SSH->Auth like this:

Specifying the Location of the Private Key in PuTTY
Specifying the Location of the Private Key in PuTTY

In the box on the right, browse for the location of your private key and save your connection settings by going to the top “Sessions” tab.

Now when you log in, your client will present your private key to the server, which will verify it again the public key in “authorized_keys”. If all goes well, it should now log you in like this:

Logged in via SSH

Disabling Root Login with Password

The next step is to disable root login with a password, and only allow login with a private key. In an earlier tutorial, we saw how to disable root logins entirely. To ensure that you can only login to root using an SSH key, we have to change the statement from:

PermitRootLogin no

to

PermitRootLogin without-password

Now restart the SSH service as before, and you’re done! We have successfully used SSH keys to log into our VPS server and disabled root logins without a password.

Using SSH Keys for Other Users

If you’re uncomfortable about allowing root logins in the first place, then you can configure SSH keys to be used with any other user. Each user has their own “authorized_keys” file.

 Instead of this location for root:

/root/.ssh/authorized_keys

It will become

/username/.ssh/

Where you replace username with the name of the specific user for whom you want to enable SSH logins.

With the usage of SSH keys and disabling root logins, your server is now far more secure than it was before. If you’ve already changed your SSH ports as mentioned in a previous article, then you’re pretty much set. Congratulations!

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Related Posts

Git Bisect: A Step-by-Step Tutorial

Git bisect is a useful tool that git provides, allowing you to narrow down the commit that introduced a bug in your project.

How to Use sed to Replace Strings in Files

The "Stream Editor" tool - the "sed" command in Linux, is often used to replace strings in files. Here's how to do it.

Echo vs Printf in Bash: What’s the Difference?

Echo and printf can both be used in bash for outputting text. However, echo is for quick output, whereas printf gives you more power.

Git Rebase vs Merge vs Cherry-Pick: When to Use Each

Git has many tools for merging branches and commits. Rebasing, merging, and cherry-picking all have their uses.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!


Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup

WordPress Hosting vs. Web Hosting – What’s The Difference?

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • OpenClaw Hosting
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero® proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • Managed VPS Hosting
  • Unmanaged VPS Hosting
  • Flex VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • GPU Hosting
  • Email Hosting
  • HeroicGuard
  • Domains
  • Website Builder
  • AI Agent Hosting
Help & Support
  • NameHero Blog
  • NameHero Gaming Blog
  • Support
  • Help Center
  • Migrations
  • Affiliates
  • Gaming Affiliates
  • Call 1-855-984-6263
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2026 Name Hero, LLC. All rights reserved.
NameHero® is a registered trademark.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA