{"id":2072,"date":"2021-06-10T15:43:51","date_gmt":"2021-06-10T12:43:51","guid":{"rendered":"https:\/\/www.scalahosting.com\/kb\/?p=2072"},"modified":"2025-11-27T13:59:38","modified_gmt":"2025-11-27T11:59:38","slug":"permission-denied-publickey-error-when-connecting-over-ssh","status":"publish","type":"post","link":"https:\/\/www.scalahosting.com\/kb\/permission-denied-publickey-error-when-connecting-over-ssh\/","title":{"rendered":"SSH Permission Denied Publickey Fix"},"content":{"rendered":"<p><b>SSH often uses a key-based authentication method<\/b><span style=\"font-weight: 400;\"> that offers better security over the regular username and password authentication. On occasion, you may encounter a &#8220;Permission denied (publickey)&#8221; error.<\/span><\/p>\n<p><b>The key-based authentication system uses two keys:<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">one public<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">one private key<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">The public key resides on your server, while the private key resides on your local device. Despite the \u201cpublic\u201d portion of this error message, it indicates an issue with the key residing on your device.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">However, since the public and private keys are a matching pair, the entire set needs to be regenerated to fix this error. SSH key generation methods differ depending on<\/span><a href=\"https:\/\/www.scalahosting.com\/blog\/choosing-an-operating-system-for-your-vps\/\"><b> the Operating System<\/b><\/a> <i><span style=\"font-weight: 400;\">(OS)<\/span><\/i><b> of your device or the SSH application used. <\/b>Below you can find links to tutorials showing you how to generate key pairs on the most popular OSs:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.scalahosting.com\/kb\/how-to-generate-an-ssh-key-pair-in-windows-using-putty\/\" target=\"_blank\" rel=\"noopener\">Windows<\/a><\/li>\n<li><a href=\"https:\/\/www.scalahosting.com\/kb\/how-to-generate-an-ssh-key-pair-in-linux\/\" target=\"_blank\" rel=\"noopener\">Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.scalahosting.com\/kb\/how-to-generate-an-ssh-key-pair-in-mac-os\/\" target=\"_blank\" rel=\"noopener\">macOS<\/a><\/li>\n<\/ul>\n<h2><span style=\"font-weight: 400;\">Alternative\u00a0 Causes<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">While the primary issue with the error in question is a problem with the keys, other possibilities exist. Most root causes still stem from issues with<\/span><b> the <\/b><a href=\"https:\/\/www.scalahosting.com\/blog\/what-is-ssh-and-how-to-use-it\/\"><b>SSH connection<\/b><\/a><b> information used- for example:<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Incorrect SSH username<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Outdated IP address or hostname<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Wrong password<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">The primary method of resolving this error is to correct the mismatching information in <\/span><b>your public and private keys or simply regenerate the keys.<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SSH often uses a key-based authentication method that offers better security over the regular username and password authentication. On occasion, you may encounter a &#8220;Permission denied (publickey)&#8221; error. The key-based authentication system uses two keys: one public one private key The public key resides on your server, while the private key resides on your local [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_seopress_robots_primary_cat":"none","_seopress_titles_title":"SSH Permission Denied Publickey Fix | ScalaHosting KB","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":""},"categories":[34],"tags":[],"class_list":["post-2072","post","type-post","status-publish","format-standard","hentry","category-web-hosting"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/2072","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/comments?post=2072"}],"version-history":[{"count":3,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/2072\/revisions"}],"predecessor-version":[{"id":5875,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/2072\/revisions\/5875"}],"wp:attachment":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/media?parent=2072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/categories?post=2072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/tags?post=2072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}