我最近将我的密钥导入到一台新机器 (Mac) 并忘记将权限修改为 600。这样做时,我不小心写了chown
而不是chmod
. 奇怪的是,这解决了权限问题,如下所示:
% git pull origin develop
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/m/.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 "/Users/m/.ssh/id_rsa": bad permissions
git@<redacted>: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
%
% sudo chown 600 ~/.ssh/id_rsa
Password:
%
% ls -l ~/.ssh/id_rsa
-rw-r--r--@ 1 600 staff 1679 Mar 25 15:14 /Users/m/.ssh/id_rsa
%
% git pull origin develop
From <redacted>
* branch develop -> FETCH_HEAD
Already up to date.
%
% ssh <redacted>
The authenticity of host '<redacted> (<redacted>)' can't be established.
ECDSA key fingerprint is <redacted>.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '<redacted>' (ECDSA) to the list of known hosts.
Warning: your password will expire in 5 days
Last login: Fri Jul 27 19:51:32 2018 from <redacted>
-bash-4.2$
为什么会这样?