{"id":5057,"date":"2023-07-20T01:23:26","date_gmt":"2023-07-20T01:23:26","guid":{"rendered":"https:\/\/arzhost.com\/blogs\/?p=5057"},"modified":"2024-09-24T21:03:17","modified_gmt":"2024-09-24T16:03:17","slug":"how-to-fix-ssh-permission-denied-error","status":"publish","type":"post","link":"https:\/\/arzhost.com\/blogs\/how-to-fix-ssh-permission-denied-error\/","title":{"rendered":"How to Fix SSH Permission Denied Error"},"content":{"rendered":"\n<p>After changing permission-related parameters on the SSH server How to Fix SSH Failed Permission Denied? the problem manifests itself. The installation of a new product or the creation of new users are typical cases.<\/p>\n\n\n\n<p>You will discover How to Fix SSH Failed Permission Denied? error and reconnect to your <a href=\"https:\/\/arzhost.com\/blogs\/ssh-to-connect-to-a-remote-server-in-linux-or-windows\/\" data-type=\"link\" data-id=\"https:\/\/arzhost.com\/blogs\/ssh-to-connect-to-a-remote-server-in-linux-or-windows\/\">SSH server<\/a> in this article.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>SSH server on the distant system and SSH client on the local machine<\/li>\n\n\n\n<li>A username and password for the remote server (for password-based login)<\/li>\n\n\n\n<li>A user account with root or sudo access<\/li>\n<\/ol>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/arzhost.com\/blogs\/how-to-fix-ssh-permission-denied-error\/#How_to_Fix_SSH_Failed_Permission_Denied\" >How to Fix SSH Failed Permission Denied&nbsp;<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/arzhost.com\/blogs\/how-to-fix-ssh-permission-denied-error\/#How_to_fix_SSH_Permission_denied\" >How to fix SSH Permission denied?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/arzhost.com\/blogs\/how-to-fix-ssh-permission-denied-error\/#Solution_1_Enable_Password_Authentication\" >Solution 1: Enable Password Authentication<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/arzhost.com\/blogs\/how-to-fix-ssh-permission-denied-error\/#Solution_2_Change_File_System_Permissions\" >Solution 2: Change File System Permissions<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Fix_SSH_Failed_Permission_Denied\"><\/span><strong>How to Fix SSH Failed Permission Denied&nbsp;<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><u>When attempting to SSH onto a server, the SSH Permission denied error appears:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Refusal of permission (publickey, gssapi-keyex, gssapi-with-mic)<\/li>\n<\/ul>\n\n\n\n<p>The tried authentication methods that were unsuccessful at connection initiation are listed in the bracket after the phrase &#8220;Permission denied.&#8221; The error gives a false impression that the public key is the problem.<\/p>\n\n\n\n<p>SSH server configuration file sshd config might be a contributing factor in the error. The authorized keys file may also not have enough permissions, which is another issue.<\/p>\n\n\n\n<p>The list of public keys for clients who are permitted to SSH onto the server is contained in this file. The system cannot read from the file as a result, and the Permission denied error is returned.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_fix_SSH_Permission_denied\"><\/span><strong>How to fix SSH Permission denied?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Both solutions contain steps you need to perform on the server side. Start by opening the terminal on your server and proceed with one of the solutions below.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Solution_1_Enable_Password_Authentication\"><\/span><strong>Solution 1: Enable Password Authentication<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you want to use a password to access the SSH server, a solution for fixing the Permission denied error is to enable password login in the sshd_config file.<\/p>\n\n\n\n<p><u>To do this, open the file in a text editor.&nbsp; This example uses the nano editor:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>sudo nano \/etc\/ssh\/sshd_config<\/code><\/li>\n<\/ul>\n\n\n\n<p>In the file, find the Password Authentication line and make sure it ends with yes.<\/p>\n\n\n\n<p><iframe title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/CXohBAxgL9w\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n\n\n\n<p>Find the ChallengeResponseAuthentication option and disable it by adding no.<\/p>\n\n\n\n<p><u>If lines are commented out, remove the hash sign # to uncomment them.<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Save the file, then shut down.<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>By entering the following command, the SSH service can be restarted:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>systemctl sudo restart sshd<\/code><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Solution_2_Change_File_System_Permissions\"><\/span><strong>Solution 2: Change File System Permissions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Using the password-based login as the SSH authentication method is not recommended due to security concerns. Therefore, the following solution may be preferable since it troubleshoots the public key authentication method.<\/p>\n\n\n\n<p><u>First, open the sshd_config file using a text editor:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>sudo nano \/etc\/ssh\/sshd_config<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>In the file, make sure the following options are set as follows:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>PermitRootLogin no<\/code><\/li>\n\n\n\n<li><code>PubkeyAuthentication yes<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>By adding the hash sign at the beginning of the line, you can comment out the GSSAPI-related options:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Yes for #GSSAPIAuthentication<\/code><\/li>\n\n\n\n<li><code>Credentials for #GSSAPICleanup no<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>Additionally, confirm that the UsePAM line is set to yes:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>No UsePAM<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>Restart the sshd service after saving the file:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>sshd systemctl restart<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>Go to your home folder now, and look at the permissions:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>ls -ld<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>Use the chmod command to modify your owner permissions if they are not set to read, write, and execute (drwx\u2014\u2014\u2014):<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\/home\/[your-username] chmod 0700<\/code><\/li>\n<\/ul>\n\n\n\n<p>Recheck the permissions in the. ssh folder now:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><u><code>ls \u2013ld<\/code><\/u><\/li>\n<\/ul>\n\n\n\n<p><u>Additionally, the file owner should be able to read, write, and execute in this directory. Use chmod once more to enforce them:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\/home\/your home\/.ssh chmod 0700<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>The authorized keys file is located in the. ssh folder. Verify its authorizations using:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>authorized keys: ls -ld<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>Read and write permissions must be granted to the file owner. Use: to set them:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\/home\/[username]\/.ssh\/authorized keys chmod 0600<\/code><\/li>\n<\/ul>\n\n\n\n<p><span style=\"color: #000000;\"><strong>How to Fix SSH Failed Permission Denied file?<\/strong><\/span> Now attempt to log in once more using the key pair. A successful login attempt is shown in the output below.<\/p>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>The steps required How to Fix SSH Failed Permission Denied file? (publickey, gssapi-keyex, gssapi-with-mic) errors were covered in this tutorial. You should be able to correct the problem and successfully <a href=\"https:\/\/en.wikipedia.org\/wiki\/Secure_Shell\" target=\"_blank\" rel=\"noopener\">SSH<\/a> onto your server by following the instructions in the guide.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After changing permission-related parameters on the SSH server How to Fix SSH Failed Permission Denied? the problem manifests itself. The installation of a new product or the creation of new users are typical cases. You will discover How to Fix SSH Failed Permission Denied? error and reconnect to your SSH server in this article. How [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6027,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[98],"tags":[222,221,223,220],"table_tags":[],"class_list":["post-5057","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ssh","tag-error","tag-permission-denied","tag-solution","tag-ssh"],"_links":{"self":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/5057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/comments?post=5057"}],"version-history":[{"count":5,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/5057\/revisions"}],"predecessor-version":[{"id":8550,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/5057\/revisions\/8550"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/media\/6027"}],"wp:attachment":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/media?parent=5057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/categories?post=5057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/tags?post=5057"},{"taxonomy":"table_tags","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/table_tags?post=5057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}