SSH Key: “Permissions 0644 for 'id_rsa.pub' are too open.” on mac - Stack Overflow (https://stackoverflow.com/Content/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (Stack Overflow) (https://stackoverflow.com/opensearch.xml) (https://stackoverflow.com/questions/29933918/ssh-key-permissions-0644-for-id-rsa-pub-are-too-open-on-mac) (Feed for question 'SSH Key: “Permissions 0644 for 'id_rsa.pub' are too open.” on mac') (https://stackoverflow.com/feeds/question/29933918) (site logo) By clicking “Sign up”, you agree to our (https://stackoverflow.com/legal/terms-of-service/public) terms of service and acknowledge you have read our (https://stackoverflow.com/legal/privacy-policy) privacy policy . Sign up with Google Sign up with GitHub OR Email Password (8+ characters (at least 1 letter & 1 number)) Sign up Already have an account? (https://stackoverflow.com/users/login) Log in Skip to main content (https://stackoverflow.com/) Stack Overflow (https://stackoverflow.co/) About Products (https://stackoverflow.co/teams/) For Teams (Search…) (Click to show search) (https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f29933918%2fssh-key-permissions-0644-for-id-rsa-pub-are-too-open-on-mac) Log in (https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f29933918%2fssh-key-permissions-0644-for-id-rsa-pub-are-too-open-on-mac) Sign up Let's set up your homepage Select a few topics you're interested in: python javascript c# reactjs java android html flutter c++ node.js typescript css r php angular next.js spring-boot machine-learning sql excel ios azure docker Or search from our full list: (Search) Next You’ll be prompted to create an account to view your personalized homepage. (https://stackoverflow.com/) Home (https://stackoverflow.com/questions) Questions (https://stackoverflow.ai/) AI Assist Labs (https://stackoverflow.com/tags) Tags (https://stackoverflow.com/beta/challenges) Challenges (https://chat.stackoverflow.com/rooms/259507/stack-overflow-lobby) Chat (https://stackoverflow.blog/contributed?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=so-blog&utm_content=experiment-articles) Articles (https://stackoverflow.com/users) Users (https://stackoverflow.com/jobs?source=so-left-nav) Jobs (https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav) Companies Collectives Communities for your favorite technologies. (https://stackoverflow.com/collectives-all) Explore all Collectives Teams Ask questions, find answers and collaborate at work with Stack Overflow for Teams. (https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) Try Teams for free (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) Explore Teams (Illustration of upvote icon after it is clicked) Hang on, you can't upvote just yet. You'll need to complete a few actions and gain 15 reputation points before being able to upvote. Upvoting indicates when questions and answers are useful. (https://stackoverflow.com/help/whats-reputation) What's reputation and how do I get it? Instead, you can save this post to reference later. Save this post for later Not now (Illustration of upvote icon after it is clicked) Thanks for your vote! You now have 5 free votes weekly. Free votescount toward the total vote score does not give reputation to the author Continue to help good content that is interesting, well-researched, and useful, rise to the top! To gain full voting privileges, (https://stackoverflow.com/help/whats-reputation) earn reputation . Got it! Go to help center to learn more (https://stackoverflow.com/Content/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (https://stackoverflow.com/questions/29933918/ssh-key-permissions-0644-for-id-rsa-pub-are-too-open-on-mac) SSH Key: “Permissions 0644 for 'id_rsa.pub' are too open.” on mac (https://stackoverflow.com/questions/ask) Ask Question (2015-04-29 03:40:47Z) Asked 10 years, 6 months ago Modified (https://stackoverflow.com/questions/29933918/ssh-key-permissions-0644-for-id-rsa-pub-are-too-open-on-mac?lastactivity) (2024-08-05 19:41:05Z) 1 year, 2 months ago (Viewed 891,608 times) Viewed 892k times This question shows research effort; it is useful and clear 721 (This question does not show any research effort; it is unclear or not useful) Save this question. (https://stackoverflow.com/posts/29933918/timeline) Show activity on this post. I generate a ssh key pair on my mac and add the public key to my ubuntu server(in fact, it is a virtual machine on my mac),but when I try to login the ubuntu server,it says: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for '/Users/tudouya/.ssh/vm/vm_id_rsa.pub' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: /Users/tudouya/.ssh/vm/vm_id_rsa.pub Permission denied (publickey,password). I have tried many ways to solve this, change the key file mode, change the folder mode,as some answer on stackoverflow,but it doesn't work.the key file permission: vm dir: drwxr-xr-x 4 tudouya staff 136 4 29 10:37 vm key file: -rw------- 1 tudouya staff 1679 4 29 10:30 vm_id_rsa -rw-r--r-- 1 tudouya staff 391 4 29 10:30 vm_id_rsa.pub please give me some idea... =========================================I write the host infomation to ssh_config: Host ubuntuvm Hostname 10.211.55.17 PreferredAuthentications publickey IdentityFile /Users/tudouya/.ssh/vm/vm_id_rsa.pub I run command "ssh -v ubuntuvm",it displays: ssh -v ubuntuvm OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 debug1: Reading configuration data /etc/ssh_config debug1: /etc/ssh_config line 20: Applying options for * debug1: /etc/ssh_config line 103: Applying options for * debug1: /etc/ssh_config line 175: Applying options for ubuntuvm debug1: Connecting to 10.211.55.17 [10.211.55.17] port 22. debug1: Connection established. debug1: identity file /Users/tudouya/.ssh/vm/vm_id_rsa.pub type 1 debug1: identity file /Users/tudouya/.ssh/vm/vm_id_rsa.pub-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.2 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-8 debug1: match: OpenSSH_6.6.1p1 Ubuntu-8 pat OpenSSH* debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Server host key: RSA 55:6d:4f:0f:23:51:ac:8e:70:01:ec:0e:62:9e:1c:10 debug1: Host '10.211.55.17' is known and matches the RSA host key. debug1: Found key in /Users/tudouya/.ssh/known_hosts:54 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Offering RSA public key: /Users/tudouya/.ssh/vm/vm_id_rsa.pub debug1: Server accepts key: pkalg ssh-rsa blen 279 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for '/Users/tudouya/.ssh/vm/vm_id_rsa.pub' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: /Users/tudouya/.ssh/vm/vm_id_rsa.pub debug1: No more authentication methods to try. Permission denied (publickey,password). (https://stackoverflow.com/questions/tagged/ssh) (show questions tagged 'ssh') ssh (https://stackoverflow.com/questions/tagged/permissions) (show questions tagged 'permissions') permissions (https://stackoverflow.com/questions/tagged/key) (show questions tagged 'key') key (https://stackoverflow.com/q/29933918) (Short permalink to this question) Share (https://stackoverflow.com/posts/29933918/edit) Improve this question Follow Follow this question to receive notifications (https://stackoverflow.com/posts/29933918/revisions) (show all edits to this post) edited (2015-04-29 15:31:42Z) Apr 29, 2015 at 15:31 (https://stackoverflow.com/users/3392958/%e5%9c%9f%e8%b1%86%e4%b8%ab) 土豆丫 asked (2015-04-29 03:40:47Z) Apr 29, 2015 at 3:40 (https://stackoverflow.com/users/3392958/%e5%9c%9f%e8%b1%86%e4%b8%ab) (土豆丫's user avatar) (https://stackoverflow.com/users/3392958/%e5%9c%9f%e8%b1%86%e4%b8%ab) 土豆丫 (reputation score) 7,315 (3 gold badges) 3 3 gold badges (17 silver badges) 17 17 silver badges (16 bronze badges) 16 16 bronze badges 5 (number of 'useful comment' votes received) 1 Could you edit your question to include the specific ssh command that you're running? If the key file in question is specified in the ssh config file, please include the relevant line(s) from the config file as well. Kenster – (https://stackoverflow.com/users/13317/kenster) (25,765 reputation) Kenster 2015-04-29 10:10:59 +00:00 Commented (2015-04-29 10:10:59Z, License: CC BY-SA 3.0) Apr 29, 2015 at 10:10 To me was "bad permissions" insign – (https://stackoverflow.com/users/530197/insign) (5,853 reputation) insign 2017-05-25 20:23:57 +00:00 Commented (2017-05-25 20:23:57Z, License: CC BY-SA 3.0) May 25, 2017 at 20:23 (number of 'useful comment' votes received) 2 I face this problem when add -i id_rsa.pub at the ssh command use for connection. Seems that enforcing to use some public key on the ssh command force to ask for password (even when the passphrase was empty, at least on my case) Diego Andrés Díaz Espinoza – (https://stackoverflow.com/users/2658381/diego-andr%c3%a9s-d%c3%adaz-espinoza) (669 reputation) Diego Andrés Díaz Espinoza 2020-02-04 18:32:59 +00:00 Commented (2020-02-04 18:32:59Z, License: CC BY-SA 4.0) Feb 4, 2020 at 18:32 (number of 'useful comment' votes received) 5 It's actually insane that these guys take the effort to print that message, including the current permission value, but don't tell you what should the permission be. It's like a "I could tell you, but this is Linux, so I'll keep it cryptic so you have to Google and waste time" attitude. Chris Vilches – (https://stackoverflow.com/users/4757175/chris-vilches) (1,187 reputation) Chris Vilches 2022-03-31 08:35:55 +00:00 Commented (2022-03-31 08:35:55Z, License: CC BY-SA 4.0) Mar 31, 2022 at 8:35 (number of 'useful comment' votes received) 1 @DiegoAndrésDíazEspinoza for ssh -i you should specify a private key. For ssh-copy-id -i you should specify a public key! what's happening for you is you are doing ssh and specifying a public key(wrong move), and it thinks you're specifying a private key , uses it as a private key, that then fails so it asks for a password cos the ssh server is set to allow passwords when keys don't work barlop – (https://stackoverflow.com/users/385907/barlop) (13,920 reputation) barlop 2022-06-12 17:27:21 +00:00 Commented (2022-06-12 17:27:21Z, License: CC BY-SA 4.0) Jun 12, 2022 at 17:27 (this comment was edited 3 times) (Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.) Add a comment | (Expand to show all comments on this post) 26 Answers 26 Sorted by: (https://stackoverflow.com/questions/29933918/ssh-key-permissions-0644-for-id-rsa-pub-are-too-open-on-mac?answertab=scoredesc#tab-top) Reset to default (scoredesc) Highest score (default) (trending) Trending (recent votes count more) (modifieddesc) Date modified (newest first) (createdasc) Date created (oldest first) This answer is useful 1471 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/37779390/timeline) Show activity on this post. I suggest you to do: chmod 400 ~/.ssh/id_rsa It works fine for me. (https://stackoverflow.com/a/37779390) (Short permalink to this answer) Share (https://stackoverflow.com/posts/37779390/edit) Improve this answer Follow Follow this answer to receive notifications (https://stackoverflow.com/posts/37779390/revisions) (show all edits to this post) edited (2020-08-05 09:46:16Z) Aug 5, 2020 at 9:46 (https://stackoverflow.com/users/4693496/erazihel) (Erazihel's user avatar) (https://stackoverflow.com/users/4693496/erazihel) Erazihel (reputation score) 7,645 (6 gold badges) 6 6 gold badges (34 silver badges) 34 34 silver badges (56 bronze badges) 56 56 bronze badges answered (2016-06-12 21:48:25Z) Jun 12, 2016 at 21:48 (https://stackoverflow.com/users/2224870/rick-benetti) (Rick Benetti's user avatar) (https://stackoverflow.com/users/2224870/rick-benetti) Rick Benetti (reputation score 14,895) 14.9k (2 gold badges) 2 2 gold badges (14 silver badges) 14 14 silver badges (6 bronze badges) 6 6 bronze badges Sign up to request clarification or add additional context in comments. 7 Comments Add a comment (https://stackoverflow.com/users/4361073/parasrish) parasrish (https://stackoverflow.com/users/4361073/parasrish) parasrish (2017-09-07T08:15:03.217Z) Over a year ago (Edited 2 times) “Permissions 0644 for 'id_rsa.pub' are too open." and the key was hence ignored. This was probably because i copied the key-file, from my another PC. But fixing permissions fixed the issue. thx! 2017-09-07T08:15:03.217Z+00:00 69 Reply (https://stackoverflow.com/users/916382/gerard) Gerard (https://stackoverflow.com/users/916382/gerard) Gerard (2018-02-19T09:48:58.53Z) Over a year ago (Edited 1 time) @xoxn--1'w3k4n Why is this so bad? It makes sense if people copied or otherwise poorly managed their read-write access to these sensitive files, that they should be fixed. 2018-02-19T09:48:58.53Z+00:00 2 Reply (https://stackoverflow.com/users/6287476/alisboa) ALisboa (https://stackoverflow.com/users/6287476/alisboa) ALisboa (2018-04-04T21:28:51.563Z) Over a year ago This is not duct tape. If you copied over your ids, this makes sense. 2018-04-04T21:28:51.563Z+00:00 6 Reply (https://stackoverflow.com/users/878396/nick) Nick (https://stackoverflow.com/users/878396/nick) Nick (2018-11-12T08:53:35.043Z) Over a year ago Worked for me as a solution when copying ssh keys from old computer! 2018-11-12T08:53:35.043Z+00:00 4 Reply (https://stackoverflow.com/users/1109689/h-rai) h-rai (https://stackoverflow.com/users/1109689/h-rai) h-rai (2019-04-26T02:38:50.687Z) Over a year ago Works on WSL too 2019-04-26T02:38:50.687Z+00:00 11 Reply Add a comment | Show 2 more comments This answer is useful 315 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/29948797/timeline) Show activity on this post. debug1: identity file /Users/tudouya/.ssh/vm/vm_id_rsa.pub type 1 It appears that you're trying to use the wrong key file. The file with the ".pub" extension contains the public portion of the key. The corresponding file without the ".pub" extension contains the private part of the key. When you run an ssh client to connect to a remote server, you have to provide the private key file to the ssh client. You probably have a line in the your .ssh/config file (or /etc/ssh_config ) which looks like this: IdentityFile .../.ssh/vm/vm_id_rsa.pub You need to remove the ".pub" extension from the filename: IdentityFile .../.ssh/vm/vm_id_rsa (https://stackoverflow.com/a/29948797) (Short permalink to this answer) Share (https://stackoverflow.com/posts/29948797/edit) Improve this answer Follow Follow this answer to receive notifications (https://stackoverflow.com/posts/29948797/revisions) (show all edits to this post) edited (2020-10-16 16:49:22Z) Oct 16, 2020 at 16:49 answered (2015-04-29 15:54:30Z) Apr 29, 2015 at 15:54 (https://stackoverflow.com/users/13317/kenster) (Kenster's user avatar) (https://stackoverflow.com/users/13317/kenster) Kenster (reputation score 25,765) 25.8k (23 gold badges) 23 23 gold badges (87 silver badges) 87 87 silver badges (115 bronze badges) 115 115 bronze badges 9 Comments Add a comment (https://stackoverflow.com/users/3200071/henry) Henry (https://stackoverflow.com/users/3200071/henry) Henry (2016-08-12T04:03:03.303Z) Over a year ago I was having this problem with SQLPro and had incorrectly selected the public (.pub ) file instead of the private file. 2016-08-12T04:03:03.303Z+00:00 0 Reply user3064538 user3064538 (2019-01-15T01:12:26.65Z) Over a year ago (Edited 5 times) I got this error when I did ssh -i id_ed25519.pub whereas doing ssh -i id_ed25519 works 2019-01-15T01:12:26.65Z+00:00 3 Reply (https://stackoverflow.com/users/5009004/whenitrains) whenitrains (https://stackoverflow.com/users/5009004/whenitrains) whenitrains (2020-10-23T02:19:35.367Z) Over a year ago This should not be the accepted answer. @Rick Benetti's answer is simpler and applies to more situations. 2020-10-23T02:19:35.367Z+00:00 1 Reply (https://stackoverflow.com/users/1154919/yuriy-yakubskiy) Yuriy Yakubskiy (https://stackoverflow.com/users/1154919/yuriy-yakubskiy) Yuriy Yakubskiy (2021-06-10T17:55:16.233Z) Over a year ago Big thank! The real purpose, none of the suggested worked for me. The problem reproduces only on WSL2 while working on Ubuntu18 with *.pub 2021-06-10T17:55:16.233Z+00:00 0 Reply (https://stackoverflow.com/users/16354380/thiago-andrade) Thiago Andrade (https://stackoverflow.com/users/16354380/thiago-andrade) Thiago Andrade (2024-10-25T12:07:31.253Z) Over a year ago (Edited 1 time) Big thank! Helped me a lot!!!! 2024-10-25T12:07:31.253Z+00:00 1 Reply Add a comment | Show 4 more comments This answer is useful 128 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/40134559/timeline) Show activity on this post. Key should be readable by the logged in user. Try this: chmod 400 ~/.ssh/Key_file (https://stackoverflow.com/a/40134559) (Short permalink to this answer) Share (https://stackoverflow.com/posts/40134559/edit) Improve this answer Follow Follow this answer to receive notifications (https://stackoverflow.com/posts/40134559/revisions) (show all edits to this post) edited (2023-10-30 20:06:35Z) Oct 30, 2023 at 20:06 (https://stackoverflow.com/users/3817790/naseef-chowdhury) (Naseef Chowdhury's user avatar) (https://stackoverflow.com/users/3817790/naseef-chowdhury) Naseef Chowdhury (reputation score) 2,484 (3 gold badges) 3 3 gold badges (32 silver badges) 32 32 silver badges (58 bronze badges) 58 58 bronze badges answered (2016-10-19 14:39:03Z) Oct 19, 2016 at 14:39 (https://stackoverflow.com/users/3029620/user3029620) (user3029620's user avatar) (https://stackoverflow.com/users/3029620/user3029620) user3029620 (reputation score) 1,547 (1 gold badge) 1 1 gold badge (10 silver badges) 10 10 silver badges (4 bronze badges) 4 4 bronze badges 2 Comments Add a comment (https://stackoverflow.com/users/460885/rhand) rhand (https://stackoverflow.com/users/460885/rhand) rhand (2020-05-21T03:13:58.843Z) Over a year ago With public key 400 or 600 I get invalid format doing ssh-add ~/.ssh/id_rsa.pub 2020-05-21T03:13:58.843Z+00:00 7 Reply (https://stackoverflow.com/users/1712683/harry) Harry (https://stackoverflow.com/users/1712683/harry) Harry (2022-03-04T22:08:32.057Z) Over a year ago @rhand ssh-add needs the private key not the public one 2022-03-04T22:08:32.057Z+00:00 6 Reply This answer is useful 87 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/46825802/timeline) Show activity on this post. chmod 400 path/to/filename This work for me. When I did this file I am able to connect to my EC2 instance (https://stackoverflow.com/a/46825802) (Short permalink to this answer) Share (https://stackoverflow.com/posts/46825802/edit) Improve this answer Follow Follow this answer to receive notifications answered (2017-10-19 08:36:38Z) Oct 19, 2017 at 8:36 (https://stackoverflow.com/users/5509817/muhammad-wajahat-anwar) (Muhammad Wajahat Anwar's user avatar) (https://stackoverflow.com/users/5509817/muhammad-wajahat-anwar) Muhammad Wajahat Anwar (reputation score) 1,067 (11 silver badges) 11 11 silver badges (14 bronze badges) 14 14 bronze badges Comments Add a comment This answer is useful 63 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/69217653/timeline) Show activity on this post. change your KEY permission to chmod 400 your_key.pem It should work ! (https://stackoverflow.com/a/69217653) (Short permalink to this answer) Share (https://stackoverflow.com/posts/69217653/edit) Improve this answer Follow Follow this answer to receive notifications answered (2021-09-17 04:07:01Z) Sep 17, 2021 at 4:07 (https://stackoverflow.com/users/3885429/nikhil-babu) (Nikhil Babu's user avatar) (https://stackoverflow.com/users/3885429/nikhil-babu) Nikhil Babu (reputation score) 765 (5 silver badges) 5 5 silver badges (8 bronze badges) 8 8 bronze badges 1 Comment Add a comment (https://stackoverflow.com/users/4645748/ben) Ben (https://stackoverflow.com/users/4645748/ben) Ben (2022-04-30T19:48:00.393Z) Over a year ago (https://www.cyberciti.biz/faq/unix-linux-bsd-chmod-numeric-permissions-notation-command/) cyberciti.biz/faq/… 2022-04-30T19:48:00.393Z+00:00 0 Reply This answer is useful 33 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/56766827/timeline) Show activity on this post. After running below command it works for me sudo chmod 600 /path/to/my/key.pem (https://stackoverflow.com/a/56766827) (Short permalink to this answer) Share (https://stackoverflow.com/posts/56766827/edit) Improve this answer Follow Follow this answer to receive notifications answered (2019-06-26 06:51:56Z) Jun 26, 2019 at 6:51 (https://stackoverflow.com/users/4813422/ashok) (Ashok's user avatar) (https://stackoverflow.com/users/4813422/ashok) Ashok (reputation score) 339 (3 silver badges) 3 3 silver badges (4 bronze badges) 4 4 bronze badges Comments Add a comment This answer is useful 22 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/52587977/timeline) Show activity on this post. In my case, it was a .pem file. Turns out holds good for that too. Changed permissions of the file and it worked. chmod 400 ~/.ssh/dev-shared.pem Thanks for all of those who helped above. (https://stackoverflow.com/a/52587977) (Short permalink to this answer) Share (https://stackoverflow.com/posts/52587977/edit) Improve this answer Follow Follow this answer to receive notifications answered (2018-10-01 09:20:25Z) Oct 1, 2018 at 9:20 (https://stackoverflow.com/users/4156480/vaibhav-tripathi) (Vaibhav Tripathi's user avatar) (https://stackoverflow.com/users/4156480/vaibhav-tripathi) Vaibhav Tripathi (reputation score) 333 (2 silver badges) 2 2 silver badges (10 bronze badges) 10 10 bronze badges Comments Add a comment This answer is useful 21 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/62098449/timeline) Show activity on this post. SSH keys are meant to be private so a 644 permission is too open. Binary references to set Permissions r(read) = 4 w(write) = 2 x(execute) = 1 So by adding these numbers and by passing the summed digit to chmod command,We set the permission of file/directory. The first digit sets permission for the owner, second digit for group and the third one for all other users on the system who have no right to the file. A permission of 644 means (4+2) = read/write permission for the owner (4) = read permission for the group (4) = read permission for all other users By changing the the permission of the file to 400 using chmod 400 solves the issue. As it makes the key read-only accessible to the owner. Ref: (https://www.linux.com/training-tutorials/understanding-linux-file-permissions/) https://www.linux.com/training-tutorials/understanding-linux-file-permissions/ (https://stackoverflow.com/a/62098449) (Short permalink to this answer) Share (https://stackoverflow.com/posts/62098449/edit) Improve this answer Follow Follow this answer to receive notifications (https://stackoverflow.com/posts/62098449/revisions) (show all edits to this post) edited (2020-07-16 21:07:04Z) Jul 16, 2020 at 21:07 answered (2020-05-30 05:57:49Z) May 30, 2020 at 5:57 (https://stackoverflow.com/users/8072459/ibnjunaid) (Ibnjunaid's user avatar) (https://stackoverflow.com/users/8072459/ibnjunaid) Ibnjunaid (reputation score) 522 (1 gold badge) 1 1 gold badge (6 silver badges) 6 6 silver badges (15 bronze badges) 15 15 bronze badges 2 Comments Add a comment (https://stackoverflow.com/users/784703/dany-balian) Dany Balian (https://stackoverflow.com/users/784703/dany-balian) Dany Balian (2020-07-23T15:16:56.44Z) Over a year ago if you are already using the private file (not the .pub file) then this is the right solution just chmod 400 id_rsa_privatefilename and try to connect again 2020-07-23T15:16:56.44Z+00:00 0 Reply (https://stackoverflow.com/users/11561000/jeremy) Jeremy (https://stackoverflow.com/users/11561000/jeremy) Jeremy (2022-04-29T07:28:23.457Z) Over a year ago Nice answer :o) 2022-04-29T07:28:23.457Z+00:00 0 Reply This answer is useful 17 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/54351986/timeline) Show activity on this post. Lot's of similar answers but no explanations... The error is thrown because the private key file permissions are too open. It is a security risk. Change the permissions on the private key file to be minimal (read only by owner) Change owner chown Set minimal permissions (read only to file owner) chmod 400 (https://stackoverflow.com/a/54351986) (Short permalink to this answer) Share (https://stackoverflow.com/posts/54351986/edit) Improve this answer Follow Follow this answer to receive notifications answered (2019-01-24 17:08:03Z) Jan 24, 2019 at 17:08 (https://stackoverflow.com/users/2246488/james-wierzba) (James Wierzba's user avatar) (https://stackoverflow.com/users/2246488/james-wierzba) James Wierzba (reputation score 17,758) 17.8k (16 gold badges) 16 16 gold badges (92 silver badges) 92 92 silver badges (136 bronze badges) 136 136 bronze badges Comments Add a comment This answer is useful 17 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/64385522/timeline) Show activity on this post. chmod 600 id_rsa Run above command from path where key is stored in vm ex: cd /home/opc/.ssh (https://stackoverflow.com/a/64385522) (Short permalink to this answer) Share (https://stackoverflow.com/posts/64385522/edit) Improve this answer Follow Follow this answer to receive notifications (https://stackoverflow.com/posts/64385522/revisions) (show all edits to this post) edited (2020-10-16 09:36:26Z) Oct 16, 2020 at 9:36 (https://stackoverflow.com/users/13865476/fcdt) (fcdt's user avatar) (https://stackoverflow.com/users/13865476/fcdt) fcdt (reputation score) 2,521 (5 gold badges) 5 5 gold badges (17 silver badges) 17 17 silver badges (27 bronze badges) 27 27 bronze badges answered (2020-10-16 08:25:34Z) Oct 16, 2020 at 8:25 (https://stackoverflow.com/users/5168427/hari-krishna) (Hari Krishna's user avatar) (https://stackoverflow.com/users/5168427/hari-krishna) Hari Krishna (reputation score) 301 (2 silver badges) 2 2 silver badges (3 bronze badges) 3 3 bronze badges 1 Comment Add a comment (https://stackoverflow.com/users/2057089/gene) Gene (https://stackoverflow.com/users/2057089/gene) Gene (2022-11-13T06:08:16.27Z) Over a year ago 600 gives read and write permission. 2022-11-13T06:08:16.27Z+00:00 0 Reply This answer is useful 17 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/68999407/timeline) Show activity on this post. I have similar issue and solved it by changing the permission of the respective files and folder worked for me. This is the solution which is worked for me: $ chmod 0600 ~/.ssh/id_rsa.pub $ chmod 0600 ~/.ssh/authorized_keys $ chmod 0600 ~/.ssh/id_rsa $ chmod 0700 ~/.ssh (https://stackoverflow.com/a/68999407) (Short permalink to this answer) Share (https://stackoverflow.com/posts/68999407/edit) Improve this answer Follow Follow this answer to receive notifications answered (2021-08-31 13:16:55Z) Aug 31, 2021 at 13:16 (https://stackoverflow.com/users/3948697/atul) (Atul's user avatar) (https://stackoverflow.com/users/3948697/atul) Atul (reputation score) 3,457 (34 silver badges) 34 34 silver badges (47 bronze badges) 47 47 bronze badges 1 Comment Add a comment (https://stackoverflow.com/users/53954/cory-collier) Cory Collier (https://stackoverflow.com/users/53954/cory-collier) Cory Collier (2021-12-29T14:19:34.823Z) Over a year ago (Edited 3 times) the shorthand: ``` $ chmod 0600 ~/.ssh/* $ chmod 0700 ~/.ssh ``` 2021-12-29T14:19:34.823Z+00:00 2 Reply This answer is useful 16 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/48224451/timeline) Show activity on this post. If the keys are in the ~/.ssh directory , use chmod 400 ~/.ssh/id_rsa If the keys are in different directory, use chmod 400 directory_path/id_rsa This worked for me. (https://stackoverflow.com/a/48224451) (Short permalink to this answer) Share (https://stackoverflow.com/posts/48224451/edit) Improve this answer Follow Follow this answer to receive notifications (https://stackoverflow.com/posts/48224451/revisions) (show all edits to this post) edited (2018-04-25 15:29:32Z) Apr 25, 2018 at 15:29 answered (2018-01-12 10:36:30Z) Jan 12, 2018 at 10:36 (https://stackoverflow.com/users/6289982/anirban) (Anirban's user avatar) (https://stackoverflow.com/users/6289982/anirban) Anirban (reputation score) 393 (4 silver badges) 4 4 silver badges (7 bronze badges) 7 7 bronze badges 6 Comments Add a comment (https://stackoverflow.com/users/1116230/nico-haase) Nico Haase (https://stackoverflow.com/users/1116230/nico-haase) Nico Haase (2018-01-12T10:56:42.917Z) Over a year ago How does this improve the other answers? 2018-01-12T10:56:42.917Z+00:00 2 Reply (https://stackoverflow.com/users/1556251/picarus) Picarus (https://stackoverflow.com/users/1556251/picarus) Picarus (2018-01-24T04:20:56.58Z) Over a year ago it is not the pub key that must be protected, is the private one 2018-01-24T04:20:56.58Z+00:00 4 Reply (https://stackoverflow.com/users/298627/bashan) bashan (https://stackoverflow.com/users/298627/bashan) bashan (2018-03-11T22:12:24.217Z) Over a year ago The private key has to be protected. 2018-03-11T22:12:24.217Z+00:00 0 Reply (https://stackoverflow.com/users/5234818/naveenkumar) naveenKumar (https://stackoverflow.com/users/5234818/naveenkumar) naveenKumar (2018-04-23T14:47:43.203Z) Over a year ago It works for me. I think chmod 400 ~/.ssh/id_rsa this is what you meant @Anirban. As stated above: The file with the ".pub" extension is the public key file. The corresponding file without the ".pub" extension is the private key file. We need to protect private one. 2018-04-23T14:47:43.203Z+00:00 0 Reply (https://stackoverflow.com/users/6289982/anirban) Anirban (https://stackoverflow.com/users/6289982/anirban) Anirban (2018-04-25T15:30:56.973Z) Over a year ago Edited the answer. It should be the private key. 2018-04-25T15:30:56.973Z+00:00 0 Reply Add a comment | Show 1 more comment This answer is useful 10 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/66835761/timeline) Show activity on this post. You have to run the command bellow chmod 400 /path/to/my/key.pem (https://stackoverflow.com/a/66835761) (Short permalink to this answer) Share (https://stackoverflow.com/posts/66835761/edit) Improve this answer Follow Follow this answer to receive notifications answered (2021-03-27 20:28:18Z) Mar 27, 2021 at 20:28 (https://stackoverflow.com/users/10853247/majdi-chebil) (Majdi Chebil's user avatar) (https://stackoverflow.com/users/10853247/majdi-chebil) Majdi Chebil (reputation score) 323 (3 silver badges) 3 3 silver badges (8 bronze badges) 8 8 bronze badges Comments Add a comment This answer is useful 8 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/74610832/timeline) Show activity on this post. This problem had a quick and easy fix. You just had to change the permissions on the pem file using the following command. chmod 400 /Users/yourUserName/pathOfYourFile/fileName.pem This command will make the file read only and remove all other permissions on the file (https://stackoverflow.com/a/74610832) (Short permalink to this answer) Share (https://stackoverflow.com/posts/74610832/edit) Improve this answer Follow Follow this answer to receive notifications answered (2022-11-29 08:04:43Z) Nov 29, 2022 at 8:04 (https://stackoverflow.com/users/3040433/user3040433) (user3040433's user avatar) (https://stackoverflow.com/users/3040433/user3040433) user3040433 (reputation score) 115 (2 silver badges) 2 2 silver badges (4 bronze badges) 4 4 bronze badges Comments Add a comment This answer is useful 7 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/51980757/timeline) Show activity on this post. As for me, the default mode of id_rsa is 600 , which means readable and writable . After I push this file to a git repo and pull it from another pc, sometimes the mode of the private key file becomes -rw-r--r-- . When I pull the repo with ssh after specify the private key file, it failed and prompted warnings the same with you. Following is my script. ssh-agent bash -c "ssh-add $PATH_OF_RSA/id_rsa; \ git pull git@gitee.com:someone/somerepo.git " I fix this problem just by changing the mode to 600 . chmod 600 $PATH_TO_RSA/id_rsa (https://stackoverflow.com/a/51980757) (Short permalink to this answer) Share (https://stackoverflow.com/posts/51980757/edit) Improve this answer Follow Follow this answer to receive notifications answered (2018-08-23 07:47:46Z) Aug 23, 2018 at 7:47 (https://stackoverflow.com/users/7720976/w-perrin) (W.Perrin's user avatar) (https://stackoverflow.com/users/7720976/w-perrin) W.Perrin (reputation score) 4,785 (36 silver badges) 36 36 silver badges (31 bronze badges) 31 31 bronze badges Comments Add a comment This answer is useful 6 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/53809072/timeline) Show activity on this post. giving permision 400 makes the key private and not accessible by someone unknown. It makes the key as a protected one. chmod 400 /Users/tudouya/.ssh/vm/vm_id_rsa.pub (https://stackoverflow.com/a/53809072) (Short permalink to this answer) Share (https://stackoverflow.com/posts/53809072/edit) Improve this answer Follow Follow this answer to receive notifications answered (2018-12-17 04:41:58Z) Dec 17, 2018 at 4:41 (https://stackoverflow.com/users/10799545/himanshi-singh) (Himanshi Singh's user avatar) (https://stackoverflow.com/users/10799545/himanshi-singh) Himanshi Singh (reputation score) 71 (1 silver badge) 1 1 silver badge (1 bronze badge) 1 1 bronze badge Comments Add a comment This answer is useful 5 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/51212917/timeline) Show activity on this post. If youre using a .ssh/config file try to chmod 0400 .ssh/config then: chmod 0400 .ssh/<> (https://stackoverflow.com/a/51212917) (Short permalink to this answer) Share (https://stackoverflow.com/posts/51212917/edit) Improve this answer Follow Follow this answer to receive notifications answered (2018-07-06 14:47:36Z) Jul 6, 2018 at 14:47 (https://stackoverflow.com/users/8790285/shell-leko) (Shell_Leko's user avatar) (https://stackoverflow.com/users/8790285/shell-leko) Shell_Leko (reputation score) 552 (9 silver badges) 9 9 silver badges (13 bronze badges) 13 13 bronze badges Comments Add a comment This answer is useful 5 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/56728279/timeline) Show activity on this post. Just run below to your pem's sudo chmod 600 /path/to/my/key.pem (https://stackoverflow.com/a/56728279) (Short permalink to this answer) Share (https://stackoverflow.com/posts/56728279/edit) Improve this answer Follow Follow this answer to receive notifications answered (2019-06-23 22:56:08Z) Jun 23, 2019 at 22:56 (https://stackoverflow.com/users/6095444/pravin-bansal) (Pravin Bansal's user avatar) (https://stackoverflow.com/users/6095444/pravin-bansal) Pravin Bansal (reputation score) 4,729 (1 gold badge) 1 1 gold badge (33 silver badges) 33 33 silver badges (20 bronze badges) 20 20 bronze badges Comments Add a comment This answer is useful 5 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/67671536/timeline) Show activity on this post. This should do the trick: chmod 600 id_rsa (https://stackoverflow.com/a/67671536) (Short permalink to this answer) Share (https://stackoverflow.com/posts/67671536/edit) Improve this answer Follow Follow this answer to receive notifications answered (2021-05-24 11:45:32Z) May 24, 2021 at 11:45 (https://stackoverflow.com/users/15482209/as33) (As33's user avatar) (https://stackoverflow.com/users/15482209/as33) As33 (reputation score) 107 (1 silver badge) 1 1 silver badge (4 bronze badges) 4 4 bronze badges 1 Comment Add a comment (https://stackoverflow.com/users/6525244/xxyjoel) xxyjoel (https://stackoverflow.com/users/6525244/xxyjoel) xxyjoel (2021-07-09T22:49:44.543Z) Over a year ago (Edited 1 time) request to call chmod 600 blah is not descriptive enough; as noted in an earlier comment, you need to run this command in the location where the key is stored 2021-07-09T22:49:44.543Z+00:00 0 Reply This answer is useful 5 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/72498290/timeline) Show activity on this post. I had this issue with a macbook m1, I later realized that i was missing sudo from the connection script sudo ssh -i "key.pem" ubuntu@IP_Address Ensure you are not missing the sudo in your connection script if you are using a macbook. (https://stackoverflow.com/a/72498290) (Short permalink to this answer) Share (https://stackoverflow.com/posts/72498290/edit) Improve this answer Follow Follow this answer to receive notifications (https://stackoverflow.com/posts/72498290/revisions) (show all edits to this post) edited (2022-06-04 08:32:38Z) Jun 4, 2022 at 8:32 answered (2022-06-04 08:31:41Z) Jun 4, 2022 at 8:31 (https://stackoverflow.com/users/11471794/gagofure) (gagofure's user avatar) (https://stackoverflow.com/users/11471794/gagofure) gagofure (reputation score) 83 (2 silver badges) 2 2 silver badges (9 bronze badges) 9 9 bronze badges Comments Add a comment This answer is useful 3 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/41616412/timeline) Show activity on this post. chmod 400 /etc/ssh/* works for me. (https://stackoverflow.com/a/41616412) (Short permalink to this answer) Share (https://stackoverflow.com/posts/41616412/edit) Improve this answer Follow Follow this answer to receive notifications (https://stackoverflow.com/posts/41616412/revisions) (show all edits to this post) edited (2017-03-04 14:57:10Z) Mar 4, 2017 at 14:57 (https://stackoverflow.com/users/559745/floern) (Floern's user avatar) (https://stackoverflow.com/users/559745/floern) Floern (reputation score 33,954) 34k (24 gold badges) 24 24 gold badges (106 silver badges) 106 106 silver badges (122 bronze badges) 122 122 bronze badges answered (2017-01-12 15:03:23Z) Jan 12, 2017 at 15:03 (https://stackoverflow.com/users/3322464/michal-sipek) (Michal Sipek's user avatar) (https://stackoverflow.com/users/3322464/michal-sipek) Michal Sipek (reputation score) 494 (1 gold badge) 1 1 gold badge (6 silver badges) 6 6 silver badges (25 bronze badges) 25 25 bronze badges 1 Comment Add a comment (https://stackoverflow.com/users/1015792/j2n) J2N (https://stackoverflow.com/users/1015792/j2n) J2N (2018-09-10T14:58:41.127Z) Over a year ago You can do this so long as you realize you're affecting all keys in the directory. 2018-09-10T14:58:41.127Z+00:00 3 Reply This answer is useful 3 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/47073959/timeline) Show activity on this post. Those who suggested chmod 400 id_rsa.pub did not sound right at all. It was quite possible that op used pub key instead of private key to ssh. So it might be as simple as ssh -i /Users/tudouya/.ssh/vm/vm_id_rsa (the private key) user@host to fix it. --- update --- Check this article (https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2) https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2 for how to set up ssh key (https://stackoverflow.com/a/47073959) (Short permalink to this answer) Share (https://stackoverflow.com/posts/47073959/edit) Improve this answer Follow Follow this answer to receive notifications (https://stackoverflow.com/posts/47073959/revisions) (show all edits to this post) edited (2019-01-03 01:55:10Z) Jan 3, 2019 at 1:55 answered (2017-11-02 11:15:46Z) Nov 2, 2017 at 11:15 (https://stackoverflow.com/users/301513/qiulang) (Qiulang's user avatar) (https://stackoverflow.com/users/301513/qiulang) Qiulang (reputation score 12,833) 12.8k (22 gold badges) 22 22 gold badges (99 silver badges) 99 99 silver badges (158 bronze badges) 158 158 bronze badges 1 Comment Add a comment (https://stackoverflow.com/users/1015792/j2n) J2N (https://stackoverflow.com/users/1015792/j2n) J2N (2018-09-10T14:59:44.263Z) Over a year ago Could be, although in my case when I searched for this issue and got to the answer the chmod 400 was what I needed to solve my problem. Thanks to all who helped! 2018-09-10T14:59:44.263Z+00:00 0 Reply This answer is useful 1 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/78836190/timeline) Show activity on this post. I was trying to use my public key as private key for connecting to Gitlab. That was a rookie mistake! This was my ~/.ssh/config entry: Host gitlab.com Hostname gitlab.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_ed25519.pub ^^^^^^^^^^^^^^ this is a public key id_ed25519.pub is a public key and it is readable, that's okay since it's a public key. In fact all the permissions on my private and public keys were alright: -rw------- 1 user staff 464 Dec 10 2023 id_ed25519 -rw-r--r-- 1 user staff 108 Dec 10 2023 id_ed25519.pub -rw------- 1 user staff 1766 Aug 16 2023 id_rsa -rw-r--r-- 1 user staff 381 Sep 19 2023 id_rsa.pub -rw------- 1 user staff 2655 Mar 3 2022 id_rsa2 -rw-r--r-- 1 user staff 566 Mar 3 2022 id_rsa2.pub Problem was solved by setting IdentityFile to my private key (only readable by me!) in ~/.ssh/config : IdentityFile ~/.ssh/id_ed25519 ^^^^^^^^^^ this is a private key And actually it sometimes helps to read error messages, here it literally says that the file /Users/tudouya/.ssh/vm/vm_id_rsa.pub is being taken as private key file: Permissions 0644 for '/Users/tudouya/.ssh/vm/vm_id_rsa.pub' are too open. It is required that your private key files are NOT accessible by others. (https://stackoverflow.com/a/78836190) (Short permalink to this answer) Share (https://stackoverflow.com/posts/78836190/edit) Improve this answer Follow Follow this answer to receive notifications answered (2024-08-05 19:41:05Z) Aug 5, 2024 at 19:41 (https://stackoverflow.com/users/2314737/user2314737) (user2314737's user avatar) (https://stackoverflow.com/users/2314737/user2314737) user2314737 (reputation score 29,699) 29.7k (20 gold badges) 20 20 gold badges (109 silver badges) 109 109 silver badges (126 bronze badges) 126 126 bronze badges Comments Add a comment This answer is useful -1 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/71387855/timeline) Show activity on this post. There has been a lot of great explanation above, so I recommend reading and understanding. Here is my simple step by step solution: On your terminal, run: open ~/.ssh/config In your file, you will see something similar to this (in my personal case): Host * IgnoreUnknown UseKeychain AddKeysToAgent yes IdentityFile ~/.ssh/id_ed25519.pub or like this (as per the example in this question). Hostname 10.211.55.17 PreferredAuthentications publickey IdentityFile /Users/tudouya/.ssh/vm/vm_id_rsa.pub Remove the ".pub" extention from the last line, which should look like: Hostname 10.211.55.17 PreferredAuthentications publickey IdentityFile /Users/tudouya/.ssh/vm/vm_id_rsa or in my case: Host * IgnoreUnknown UseKeychain AddKeysToAgent yes IdentityFile ~/.ssh/id_ed25519 Save the file and test your ssh connection. (https://stackoverflow.com/a/71387855) (Short permalink to this answer) Share (https://stackoverflow.com/posts/71387855/edit) Improve this answer Follow Follow this answer to receive notifications answered (2022-03-07 22:12:12Z) Mar 7, 2022 at 22:12 (https://stackoverflow.com/users/6111757/pablo-motta) (Pablo Motta's user avatar) (https://stackoverflow.com/users/6111757/pablo-motta) Pablo Motta (reputation score) 73 (1 silver badge) 1 1 silver badge (5 bronze badges) 5 5 bronze badges Comments Add a comment This answer is useful -2 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/74702033/timeline) Show activity on this post. i had similar issues and this was what i did and it worked. sudo ssh -i webhost.pem ubuntu@ipaddress (https://stackoverflow.com/a/74702033) (Short permalink to this answer) Share (https://stackoverflow.com/posts/74702033/edit) Improve this answer Follow Follow this answer to receive notifications answered (2022-12-06 11:50:22Z) Dec 6, 2022 at 11:50 (https://stackoverflow.com/users/20702082/faithful-ahamefule) (Faithful Ahamefule's user avatar) (https://stackoverflow.com/users/20702082/faithful-ahamefule) Faithful Ahamefule (reputation score) 1 1 Comment Add a comment (https://stackoverflow.com/users/2227743/eric-aya) Eric Aya (https://stackoverflow.com/users/2227743/eric-aya) Eric Aya (2022-12-06T11:58:24.39Z) Over a year ago This is the same solution as in (https://stackoverflow.com/a/72498290/2227743) this other answer . 2022-12-06T11:58:24.39Z+00:00 1 Reply This answer is useful -12 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://stackoverflow.com/posts/34736623/timeline) Show activity on this post. I removed the .pub file , and it worked. (https://stackoverflow.com/a/34736623) (Short permalink to this answer) Share (https://stackoverflow.com/posts/34736623/edit) Improve this answer Follow Follow this answer to receive notifications (https://stackoverflow.com/posts/34736623/revisions) (show all edits to this post) edited (2016-05-09 04:20:00Z) May 9, 2016 at 4:20 (https://stackoverflow.com/users/4688119/box-box-box-box) (Box Box Box Box's user avatar) (https://stackoverflow.com/users/4688119/box-box-box-box) Box Box Box Box (reputation score) 5,398 (10 gold badges) 10 10 gold badges (52 silver badges) 52 52 silver badges (71 bronze badges) 71 71 bronze badges answered (2016-01-12 06:05:49Z) Jan 12, 2016 at 6:05 (https://stackoverflow.com/users/2942483/user2942483) (user2942483's user avatar) (https://stackoverflow.com/users/2942483/user2942483) user2942483 (reputation score) 7 2 Comments Add a comment (https://stackoverflow.com/users/3200071/henry) Henry (https://stackoverflow.com/users/3200071/henry) Henry (2016-08-12T04:03:45.13Z) Over a year ago Removing the .pub file is not necessary. It will also mean you don't have a record of the public key on your machine for later use. 2016-08-12T04:03:45.13Z+00:00 1 Reply (https://stackoverflow.com/users/65589/dannysauer) dannysauer (https://stackoverflow.com/users/65589/dannysauer) dannysauer (2016-10-10T14:15:35.377Z) Over a year ago If you have OpenSSH, you can regenerate the missing public key file from the private key by using ssh-keygen -i -f /path/to/private.key > /desired/path/to/public.key . So, it's not really lost. :) 2016-10-10T14:15:35.377Z+00:00 1 Reply (https://stackoverflow.com/help/privileges/protect-questions) Protected question . To answer this question, you need to have at least 10 reputation on this site (not counting the (https://meta.stackexchange.com/questions/141648/what-is-the-association-bonus-and-how-does-it-work) association bonus ). The reputation requirement helps protect this question from spam and non-answer activity. Start asking to get answers Find the answer to your question by asking. (https://stackoverflow.com/questions/ask) Ask question Explore related questions (https://stackoverflow.com/questions/tagged/ssh) (show questions tagged 'ssh') ssh (https://stackoverflow.com/questions/tagged/permissions) (show questions tagged 'permissions') permissions (https://stackoverflow.com/questions/tagged/key) (show questions tagged 'key') key See similar questions with these tags. The Overflow Blog (https://stackoverflow.blog/2025/10/30/live-from-the-openai-forum-learning-to-code-in-the-age-of-ai/?cb=1) Live from the OpenAI forum: Learning to code in the age of AI (https://stackoverflow.blog/2025/10/31/vibe-coding-needs-a-spec-too/?cb=1) Vibe coding needs a spec, too Featured on Meta (Meta Stack Exchange) (https://meta.stackexchange.com/questions/413210/community-asks-sprint-announcement-october-november-2025?cb=1) Community Asks Sprint Announcement - October/November 2025 (Meta Stack Exchange) (https://meta.stackexchange.com/questions/414460/we-re-releasing-our-proactive-anti-spam-measure-network-wide?cb=1) We’re releasing our proactive anti-spam measure network-wide (Meta Stack Overflow) (https://meta.stackoverflow.com/questions/435293/opinion-based-questions-alpha-experiment-on-stack-overflow?cb=1) Opinion-based questions alpha experiment on Stack Overflow Community activity Last 1 hr Users online activity 5508 users online Number of questions asked 5 questions Number of questions that received an answer 13 answers Number of comments posted 33 comments Number of upvotes on posts 134 upvotes Popular tags Popular tags (https://stackoverflow.com/questions/tagged/node.js) node.js (https://stackoverflow.com/questions/tagged/c) c (https://stackoverflow.com/questions/tagged/c#) c# (https://stackoverflow.com/questions/tagged/css) css (https://stackoverflow.com/questions/tagged/python) python (https://stackoverflow.com/questions/tagged/java) java Popular unanswered question Popular unanswered question (https://stackoverflow.com/questions/79806215) How to create a dialogbox main window in C using Visual Studio 2022? (https://stackoverflow.com/questions/tagged/c) c (https://stackoverflow.com/questions/tagged/modal-dialog) modal-dialog (https://stackoverflow.com/questions/tagged/visual-studio-2022) visual-studio-2022 (https://stackoverflow.com/users/31792794) (User avatar) (https://stackoverflow.com/users/31792794) ciddu42 1 (Friday, October 31, 2025 at 9:16:40 PM UTC) 2 hours ago Linked (https://stackoverflow.com/questions/60137786/failed-to-connect-to-the-host-via-ssh-permission-denied-publickey?lq=1) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/60137786/failed-to-connect-to-the-host-via-ssh-permission-denied-publickey?noredirect=1&lq=1) "Failed to connect to the host via ssh: Permission denied (publickey).", (https://stackoverflow.com/questions/47316981/gcloud-permission-denied-public-key-when-ssh-ing-to-server?lq=1) (Question score (upvotes - downvotes)) 4 (https://stackoverflow.com/questions/47316981/gcloud-permission-denied-public-key-when-ssh-ing-to-server?noredirect=1&lq=1) gcloud: permission denied (public key) when ssh-ing to server (https://stackoverflow.com/questions/57913307/unable-to-ssh-using-git-config-file?lq=1) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/57913307/unable-to-ssh-using-git-config-file?noredirect=1&lq=1) Unable to ssh using git config file (https://stackoverflow.com/questions/63328046/vscode-remote-ssh-not-working-on-new-computer?lq=1) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/63328046/vscode-remote-ssh-not-working-on-new-computer?noredirect=1&lq=1) VsCode remote-ssh not working on new computer (https://stackoverflow.com/questions/51031300/in-docker-git-lfs-giving-error-credentials-for-https-github-not-found?lq=1) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/51031300/in-docker-git-lfs-giving-error-credentials-for-https-github-not-found?noredirect=1&lq=1) In Docker, git-lfs giving error: credentials for https://github.... not found (https://stackoverflow.com/questions/74796258/gitgitlab-com-permission-denied-publickey-fatal-could-not-read-from-remote?lq=1) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/74796258/gitgitlab-com-permission-denied-publickey-fatal-could-not-read-from-remote?noredirect=1&lq=1) git@gitlab.com: Permission denied (publickey). fatal: Could not read from remote repository (https://stackoverflow.com/questions/78690987/unable-to-fix-ssh-permission-denied-publickey-error?lq=1) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/78690987/unable-to-fix-ssh-permission-denied-publickey-error?noredirect=1&lq=1) Unable to fix SSH Permission denied (publickey) error (https://stackoverflow.com/questions/29982831/ssh-key-does-not-work-on-a-fresh-linux-install?lq=1) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/29982831/ssh-key-does-not-work-on-a-fresh-linux-install?noredirect=1&lq=1) SSH Key does not work on a fresh linux install (https://stackoverflow.com/questions/50473374/error-trying-to-connect-to-google-cloud-over-ssh?lq=1) (Question score (upvotes - downvotes)) -1 (https://stackoverflow.com/questions/50473374/error-trying-to-connect-to-google-cloud-over-ssh?noredirect=1&lq=1) Error trying to connect to google cloud over SSH (https://stackoverflow.com/questions/49253574/git-ssh-authentification-problems?lq=1) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/49253574/git-ssh-authentification-problems?noredirect=1&lq=1) Git ssh authentification problems (https://stackoverflow.com/questions/linked/29933918?lq=1) See more linked questions Related (https://stackoverflow.com/questions/8480209/github-permission-denied-public-key?rq=3) (Question score (upvotes - downvotes)) 4 (https://stackoverflow.com/questions/8480209/github-permission-denied-public-key?rq=3) GitHub Permission Denied (Public Key) (https://stackoverflow.com/questions/9560892/permissions-error-github-ssh-key-not-recognized?rq=3) (Question score (upvotes - downvotes)) 19 (https://stackoverflow.com/questions/9560892/permissions-error-github-ssh-key-not-recognized?rq=3) Permissions error github (ssh key not recognized) (https://stackoverflow.com/questions/11400487/error-permission-denied-publickey?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/11400487/error-permission-denied-publickey?rq=3) Error: Permission denied (publickey) (https://stackoverflow.com/questions/13606363/could-not-load-id-rsa-as-a-rsa1-public-key?rq=3) (Question score (upvotes - downvotes)) 38 (https://stackoverflow.com/questions/13606363/could-not-load-id-rsa-as-a-rsa1-public-key?rq=3) Could not load id_rsa as a RSA1 public key (https://stackoverflow.com/questions/20688844/sshd-gives-error-could-not-open-authorized-keys-although-permissions-seem-corre?rq=3) (Question score (upvotes - downvotes)) 43 (https://stackoverflow.com/questions/20688844/sshd-gives-error-could-not-open-authorized-keys-although-permissions-seem-corre?rq=3) SSHD Gives error could not open Authorized Keys, although permissions seem correct (https://stackoverflow.com/questions/33933836/cant-connect-to-github-via-ssh-permission-denied-public-key?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/33933836/cant-connect-to-github-via-ssh-permission-denied-public-key?rq=3) Can't connect to github via ssh; Permission denied (public key) (https://stackoverflow.com/questions/39074696/id-rsa-pub-is-not-a-public-key-file?rq=3) (Question score (upvotes - downvotes)) 8 (https://stackoverflow.com/questions/39074696/id-rsa-pub-is-not-a-public-key-file?rq=3) id_rsa.pub is not a public key file (https://stackoverflow.com/questions/44744278/github-ssh-key-issue-permission-denied?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/44744278/github-ssh-key-issue-permission-denied?rq=3) GitHub SSH Key Issue - Permission Denied (https://stackoverflow.com/questions/48328446/id-rsa-pub-file-ssh-error-invalid-format?rq=3) (Question score (upvotes - downvotes)) 77 (https://stackoverflow.com/questions/48328446/id-rsa-pub-file-ssh-error-invalid-format?rq=3) id_rsa.pub file SSH Error: invalid format (https://stackoverflow.com/questions/73634121/permission-denied-publickey-gssapi-keyex-gssapi-with-mic-on-mac?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/73634121/permission-denied-publickey-gssapi-keyex-gssapi-with-mic-on-mac?rq=3) Permission denied (publickey,gssapi-keyex,gssapi-with-mic) on Mac (https://stackexchange.com/questions?tab=hot) Hot Network Questions (Unix & Linux Stack Exchange) (https://unix.stackexchange.com/questions/800861/how-to-get-every-lines-between-nth-and-n1th-match-of-grep-in-text-file) How to get every lines between nth and (n+1)th match of grep in text file (Japanese Language Stack Exchange) (https://japanese.stackexchange.com/questions/110393/meaning-of-%e5%a5%bd%e3%81%8d%e3%81%ab%e3%81%99%e3%82%8b%e3%81%a8%e3%82%82) Meaning of 好きにするとも (Science Fiction & Fantasy Stack Exchange) (https://scifi.stackexchange.com/questions/300824/what-was-the-first-story-to-use-the-term-artificial-intelligence) What was the first story to use the term "artificial intelligence"? (Russian Language Stack Exchange) (https://russian.stackexchange.com/questions/29227/what-is-the-meaning-of-%d0%b2-%d0%bb%d0%be%d1%81%d0%ba-%d1%83%d0%bb%d0%be%d0%b6%d0%b8%d1%82%d1%8c) What is the meaning of "в лоск уложить"? (Aviation Stack Exchange) (https://aviation.stackexchange.com/questions/113552/what-is-the-handle-on-the-captains-seat-in-the-an-12) What is the handle on the captain's seat in the An-12? (Electrical Engineering Stack Exchange) (https://electronics.stackexchange.com/questions/760015/strange-bjt-biasing-design) Strange BJT biasing design (Retrocomputing Stack Exchange) (https://retrocomputing.stackexchange.com/questions/32227/is-there-any-extant-documentation-for-the-mts-fmt-formatting-program) Is there any extant documentation for the MTS fmt formatting program? (Puzzling Stack Exchange) (https://puzzling.stackexchange.com/questions/134734/two-semicircles-in-a-regular-pentagon) Two semicircles in a regular pentagon (Worldbuilding Stack Exchange) (https://worldbuilding.stackexchange.com/questions/270553/preventing-overplanting-overharvesting-of-a-coconut-based-currency) Preventing overplanting/overharvesting of a coconut based currency (TeX - LaTeX Stack Exchange) (https://tex.stackexchange.com/questions/754242/stack-characters-closer-than-their-outline) Stack characters closer than their outline (Stack Overflow) (https://stackoverflow.com/questions/79805867/stdconstruct-at-vs-placement-new-additional-move-copy-constructor-call) std::construct_at vs placement new; additional move/copy constructor call (Physics Stack Exchange) (https://physics.stackexchange.com/questions/863694/velocity-of-efflux-when-the-area-of-hole-is-equal-to-the-cross-sectional-area-of) Velocity of efflux when the area of hole is equal to the cross sectional area of the container (Mathematics Stack Exchange) (https://math.stackexchange.com/questions/5105964/expected-value-of-the-largest-distance-from-a-random-point-to-an-edge-in-a-unit) Expected value of the largest distance from a random point to an edge in a unit square (Stack Overflow) (https://stackoverflow.com/questions/79804789/template-for-function-with-n-inputs) Template for function with N inputs (Law Stack Exchange) (https://law.stackexchange.com/questions/112283/given-a-law-how-can-i-find-all-the-court-interpretations-of-that-law) Given a law, how can I find all the court interpretations of that law? (Travel Stack Exchange) (https://travel.stackexchange.com/questions/201526/late-night-transfer-from-sha-to-pvg-airport-single-ticket) Late-night transfer from SHA to PVG airport (single ticket) (Astronomy Stack Exchange) (https://astronomy.stackexchange.com/questions/61857/why-arent-there-green-stars) Why aren't there green stars? (Aviation Stack Exchange) (https://aviation.stackexchange.com/questions/113545/odd-approach-pattern) Odd approach pattern? (Biblical Hermeneutics Stack Exchange) (https://hermeneutics.stackexchange.com/questions/111265/why-did-jesus-use-pearls-in-his-teachings) Why did Jesus use pearls in his teachings? (TeX - LaTeX Stack Exchange) (https://tex.stackexchange.com/questions/754244/macro-for-missing-words) Macro for missing word(s) (Travel Stack Exchange) (https://travel.stackexchange.com/questions/201511/hotel-rooms-for-rent-during-the-week) Hotel Rooms for rent during the week (Academia Stack Exchange) (https://academia.stackexchange.com/questions/223872/stating-that-ai-was-not-used-in-my-thesis) Stating that AI was not used in my thesis (TeX - LaTeX Stack Exchange) (https://tex.stackexchange.com/questions/754252/set-minimum-height-for-math-lines) Set minimum height for math lines (Literature Stack Exchange) (https://literature.stackexchange.com/questions/30942/identify-poem-my-gentle-child-behold-this-horse-a-noble-animal-of-course) Identify poem: My gentle child, behold this horse, / a noble animal of course, / though not to be relied on (https://stackoverflow.com/feeds/question/29933918) (Feed of this question and its answers) Question feed Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. (https://stackoverflow.com/feeds/question/29933918) () Why are you flagging this comment? (45) Probable spam. This comment promotes a product, service or website while (https://stackoverflow.com/help/promotion) failing to disclose the author's affiliation . (20) Unfriendly or contains harassment/bigotry/abuse. This comment is unkind, insulting or attacks another person or group. Learn more in our (https://stackoverflow.com/conduct/abusive-behavior) Abusive behavior policy . (39) Not needed. This comment is not relevant to the post. (19) Something else. A problem not listed above. Try to be as specific as possible. Flag comment Cancel You have 0 flags left today (GPP Locator) (https://stackoverflow.com/) (https://stackoverflow.com/) Stack Overflow (https://stackoverflow.com/questions) Questions (https://stackoverflow.com/help) Help (https://chat.stackoverflow.com/?tab=explore) Chat (https://stackoverflow.co/) Products (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=teams) Teams (https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=advertising) Advertising (https://stackoverflow.co/advertising/employer-branding/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=talent) Talent (https://stackoverflow.co/) Company (https://stackoverflow.co/) About (https://stackoverflow.co/company/press/) Press (https://stackoverflow.co/company/work-here/) Work Here (https://stackoverflow.com/legal) Legal (https://stackoverflow.com/legal/privacy-policy) Privacy Policy (https://stackoverflow.com/legal/terms-of-service/public) Terms of Service (https://stackoverflow.com/contact) Contact Us Your Privacy Choices (https://policies.stackoverflow.co/stack-overflow/cookie-policy) Cookie Policy (https://stackexchange.com/) Stack Exchange Network (https://stackexchange.com/sites#technology) Technology (https://stackexchange.com/sites#culturerecreation) Culture & recreation (https://stackexchange.com/sites#lifearts) Life & arts (https://stackexchange.com/sites#science) Science (https://stackexchange.com/sites#professional) Professional (https://stackexchange.com/sites#business) Business (https://api.stackexchange.com/) API (https://data.stackexchange.com/) Data (https://stackoverflow.blog/?blb=1) Blog (https://www.facebook.com/officialstackoverflow/) Facebook (https://twitter.com/stackoverflow) Twitter (https://linkedin.com/company/stack-overflow) LinkedIn (https://www.instagram.com/thestackoverflow) Instagram Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under (https://stackoverflow.com/help/licensing) CC BY-SA . rev 2025.10.31.36208 By continuing to use this website, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our (https://policies.stackoverflow.co/stack-overflow/cookie-policy/) Cookie Policy . By exiting this window, default cookies will be accepted. To reject cookies, select an option from below. Necessary cookies only Customize settings