SSH Key: “Permissions 0644 for 'id_rsa.pub' are too open.” on mac

后端 未结 17 2093
[愿得一人]
[愿得一人] 2020-11-28 00:50

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:

17条回答
  •  独厮守ぢ
    2020-11-28 01:26

    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/

提交回复
热议问题