{"id":1019,"date":"2026-08-30T22:38:21","date_gmt":"2026-08-30T22:38:21","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=1019"},"modified":"2026-08-30T22:38:21","modified_gmt":"2026-08-30T22:38:21","slug":"set-up-ssh-key-authentication-vps","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/","title":{"rendered":"How to Set Up SSH Key Authentication on Your VPS"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">SSH key authentication is the most secure and convenient way to log into your VPS. Instead of typing a password each time, you use a cryptographic key pair: a private key that stays on your local machine and a public key that lives on your server. This setup eliminates password brute-force attacks, speeds up logins, and lets you manage multiple servers with a single credential. This guide walks through the entire process, from generating keys to hardening your SSH daemon.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Generate an SSH Key Pair<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On your local machine (not the server), generate a new key pair with the ed25519 algorithm \u2014 it is faster, shorter, and considered more secure than RSA for most purposes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-keygen -t ed25519 -a 100 -C \"your-email@example.com\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You will be prompted for a save location (default: <code>~\/.ssh\/id_ed25519<\/code>) and an optional passphrase. A passphrase adds a second factor: even if someone steals your private key, they cannot use it without the passphrase. We recommend setting one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you need to connect to older systems that do not support ed25519, generate an RSA key instead:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-keygen -t rsa -b 4096 -C \"your-email@example.com\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">2. Copy the Public Key to Your VPS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use the <code>ssh-copy-id<\/code> utility, which appends your public key to the server&#8217;s <code>~\/.ssh\/authorized_keys<\/code> file automatically:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-copy-id -i ~\/.ssh\/id_ed25519.pub user@your-vps-ip<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If <code>ssh-copy-id<\/code> is not available, you can do it manually:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat ~\/.ssh\/id_ed25519.pub | ssh user@your-vps-ip \\\n  \"mkdir -p ~\/.ssh &amp;&amp; chmod 700 ~\/.ssh &amp;&amp; \\\n   cat &gt;&gt; ~\/.ssh\/authorized_keys &amp;&amp; chmod 600 ~\/.ssh\/authorized_keys\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3. Test the Key-Based Login<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Open a new terminal (or use <code>ssh -o IdentitiesOnly=yes<\/code>) and connect to your VPS. If everything is configured correctly, you should log in without being prompted for a password (you may still be asked for your key passphrase if you set one):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh user@your-vps-ip<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also add a config entry in <code>~\/.ssh\/config<\/code> to simplify future logins:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Host my-vps\n    HostName your-vps-ip\n    User your-username\n    IdentityFile ~\/.ssh\/id_ed25519\n    AddKeysToAgent yes<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then simply type <code>ssh my-vps<\/code> to connect.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Disable Password Authentication<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once key authentication works reliably, disable password authentication to close the door on brute-force attacks. Edit the SSH daemon configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/ssh\/sshd_config\n\n# Set these values:\nPasswordAuthentication no\nPubkeyAuthentication yes\nPermitRootLogin no\n\nsudo systemctl restart sshd<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Keep a second terminal session open when you restart SSH. If your configuration has an error, you can still recover. Never disable password auth until you have verified key-based login works \u2014 otherwise you risk locking yourself out of your own server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Managing Keys Across Multiple Servers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can reuse the same public key on multiple VPS instances, which simplifies management. However, if one server is compromised, all servers sharing that key are at risk. For high-security environments, use a dedicated key per server and store keys in a password manager or an SSH agent.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To remove access for a user, simply delete their key from <code>~\/.ssh\/authorized_keys<\/code>. This is far cleaner than rotating passwords across all users.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. Go Further with SSH Security<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">SSH key authentication is the foundation of a secure VPS. From here, you can add layers like two-factor authentication, Fail2ban, and a non-default port. If you are setting up a new server, take a moment to review our <a href=\"https:\/\/virtualserversvps.com\/\">VPS security checklist<\/a> to ensure your infrastructure is locked down from day one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With SSH keys configured and password authentication disabled, your VPS is protected against the most common automated attack vectors. The combination of cryptographic keys and a passphrase gives you security and convenience that passwords simply cannot match.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SSH key authentication is the most secure and convenient way to log into your VPS. Instead of typing a password each time, you use a cryptographic key pair: a private&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1019","post","type-post","status-publish","format-standard","hentry","category-security-compliance"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Set Up SSH Key Authentication on Your VPS - Virtual Servers VPS Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Set Up SSH Key Authentication on Your VPS\" \/>\n<meta property=\"og:description\" content=\"How to Set Up SSH Key Authentication on Your VPS\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-30T22:38:21+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/\",\"name\":\"How to Set Up SSH Key Authentication on Your VPS - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-08-30T22:38:21+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Set Up SSH Key Authentication on Your VPS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Set Up SSH Key Authentication on Your VPS - Virtual Servers VPS Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/","og_locale":"en_US","og_type":"article","og_title":"How to Set Up SSH Key Authentication on Your VPS","og_description":"How to Set Up SSH Key Authentication on Your VPS","og_url":"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-08-30T22:38:21+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/","url":"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/","name":"How to Set Up SSH Key Authentication on Your VPS - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-08-30T22:38:21+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/set-up-ssh-key-authentication-vps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Set Up SSH Key Authentication on Your VPS"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=1019"}],"version-history":[{"count":1,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1019\/revisions"}],"predecessor-version":[{"id":1020,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1019\/revisions\/1020"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=1019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=1019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=1019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}