chown 600 id_rsa 수정 권한 문제가 발생하는 이유는 무엇입니까?

chown 600 id_rsa 수정 권한 문제가 발생하는 이유는 무엇입니까?

최근에 내 키를 새 컴퓨터(Mac)로 가져왔고 권한을 600으로 수정하는 것을 잊어버렸습니다. 그렇게 하다가 실수 chownchmod. 이상하게도 여기에서 볼 수 있듯이 권한 문제가 해결되었습니다.

% 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$

왜 이런가요?

답변1

에 따르면오픈SSH소스 코드에서는 ssh파일 소유자가 를 실행하는 사용자인 경우에만 개인 키 파일에 대한 권한을 확인합니다 ssh. 파일이 다른 사용자에게 속한 경우 ssh는 파일을 읽을 수 있는 모든 사람이 해당 파일을 사용할 수 있도록 허용합니다.

if ((st.st_uid == getuid()) && (st.st_mode & 077) != 0) {
     ^^^^^^^^^^^^^^^^^^^--owner ^^^^^^^^^^^^^^^^--permissions
    error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
    error("@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @");
    error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
    ...

이 내용은 본문에 명시되어 있지 않은 것 같습니다.매뉴얼 페이지.

소스 코드에는 의도된 동작임을 나타내는 다음 주석이 포함되어 있습니다.

/*
 * if a key owned by the user is accessed, then we check the
 * permissions of the file. if the key owned by a different user,
 * then we don't care.
 */

실제로 다른 사용자에게 속한 키 파일에 대한 권한을 확인한다고 해서 보안이 향상되지는 않습니다. 파일을 읽을 수 있으면 파일 사본을 만들고 사본에 대한 권한을 제한하여 권한 검사를 피할 수 있습니다.

답변2

chmod 명령은 "모드 변경"을 나타내며 UNIX에서 "모드"라고도 알려진 파일 및 폴더의 권한 변경을 허용합니다. chown 명령은 "소유자 변경"을 나타내며 특정 파일이나 폴더의 소유자(사용자 및 그룹)를 변경할 수 있습니다.

관련 정보