{"id":1237,"date":"2018-12-26T13:25:17","date_gmt":"2018-12-26T13:25:17","guid":{"rendered":"https:\/\/chemicloud.com\/kb\/?post_type=article&#038;p=1237"},"modified":"2022-06-22T10:05:18","modified_gmt":"2022-06-22T10:05:18","slug":"ssh-authentication-refused-bad-ownership-or-modes-for-directory","status":"publish","type":"ht_kb","link":"https:\/\/chemicloud.com\/kb\/article\/ssh-authentication-refused-bad-ownership-or-modes-for-directory\/","title":{"rendered":"SSH Authentication Refused: Bad Ownership or Modes for Directory"},"content":{"rendered":"<p>If you get this error in your logs when trying to set up public key authenticated automatic logins, or while trying to SSH into your account, after setting up the public key the issue is related to permissions.<\/p>\n<p>Tailing\u00a0<em>\/var\/log\/secure<\/em>\u00a0on the target machine will be useful:<\/p>\n<pre>tail -f \/var\/log\/secure\r\nDec 26 12:30:38 server sshd[3503454]: Authentication refused: bad ownership or modes for directory \/home\/user\/.ssh<\/pre>\n<p>As you can see &#8211;\u00a0<em>bad ownership or modes for directory \/home\/user\/.ssh<\/em>.<\/p>\n<p>SSH doesn\u2019t like it if your home or\u00a0<em>~\/.ssh<\/em>\u00a0directories have group write permissions. Your home directory should be writable only by you, ~\/.ssh should be 700, and authorized_keys should be 600 :<\/p>\n<pre>chmod go-w \/home\/user\r\nchmod 700 \/home\/user\/.ssh\r\nchmod 600 \/home\/user\/.ssh\/authorized_keys<\/pre>\n<p>So fixing permissions is the way to go and have this error resolved.<\/p>\n<p class=\"p1\"><b>Tired of hassling with troubleshooting?<span class=\"Apple-converted-space\">\u00a0 <\/span>ChemiCloud is the managed hosting solution designed to save you time and money! <\/b><span class=\"s1\">\ud83e\udd13<\/span><b> Check out our <\/b><a href=\"https:\/\/chemicloud.com\/pricing#60b65e4e63b58\" target=\"_blank\" rel=\"noopener\"><span class=\"s2\"><b>web hosting <\/b><\/span><\/a><b>plans!<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you get this error in your logs when trying to set up public key authenticated automatic logins, or while trying to SSH into your account, after setting up the public key the issue is related to permissions. Tailing\u00a0\/var\/log\/secure\u00a0on the target machine will be useful: tail -f \/var\/log\/secure Dec 26&#8230;<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"ht-kb-category":[37],"ht-kb-tag":[],"class_list":["post-1237","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-ftp-and-ssh-access"],"_links":{"self":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb\/1237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/comments?post=1237"}],"version-history":[{"count":4,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb\/1237\/revisions"}],"predecessor-version":[{"id":7439,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb\/1237\/revisions\/7439"}],"wp:attachment":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/media?parent=1237"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb-category?post=1237"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb-tag?post=1237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}