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:
I suggest you to do:
chmod 400 ~/.ssh/id_rsa
It works fine for me.
Just run below to your pem's
sudo chmod 600 /path/to/my/key.pem
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.
chmod 600 id_rsa
Run above command from path where key is stored in vm ex: cd /home/opc/.ssh
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.
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