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

后端 未结 17 2013
[愿得一人]
[愿得一人] 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:31

    I suggest you to do:

    chmod 400 ~/.ssh/id_rsa

    It works fine for me.

    0 讨论(0)
  • 2020-11-28 01:31

    Just run below to your pem's

    sudo chmod 600 /path/to/my/key.pem 
    
    0 讨论(0)
  • 2020-11-28 01:32

    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.

    0 讨论(0)
  • 2020-11-28 01:34
    chmod 600 id_rsa
    

    Run above command from path where key is stored in vm ex: cd /home/opc/.ssh

    0 讨论(0)
  • 2020-11-28 01:36

    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.

    0 讨论(0)
  • 2020-11-28 01:36

    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
    
    0 讨论(0)
提交回复
热议问题