RSA private key bad permission issue

  • fennng 

I recently migrated my website to a new server. When I tried to git push my website to git server from my new server, it failed, error as below.

fennng@fengUbuntu2:~/Dropbox/fengUbuntu/wp/html$ git push
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for ‘/home/fennng/.ssh/id_rsa’ are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key “/home/fennng/.ssh/id_rsa”: bad permissions
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fennng@fengUbuntu2:~/Dropbox/fengUbuntu/wp/html$ git push
Counting objects: 9, done.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 1.41 KiB | 721.00 KiB/s, done.
Total 9 (delta 8), reused 0 (delta 0)
remote: Checking connectivity: 9, done.
To bitbucket.org:fennng/wp-files.git
70925ed..e6c612e master -> master
fennng@fengUbuntu2:~/Dropbox/fengUbuntu/wp/html$

The keys were copied from the old server. What’s wrong with it? Yes as it already stated. It’s the file’s permission. I used SFTP to copy the files over, but the permission was not set properly by the SFTP client. To fix this issue, we need to set proper permission for the id_rsa file.

Solution:

fennng@fengUbuntu2:~/.ssh$ chmod 644 *
fennng@fengUbuntu2:~/.ssh$ chmod 600 id_rsa

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注