Please make sure to add our public SSH key to your .ssh/authorized_keys file but authorized_keys is read-only



I am following this link to push my code to github using ssh. But I got an error as below when do "git push -u origin master "

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I traced down the problem and found out the key in ~/.ssh/authorized_keys which ends with “ubuntu@docker-gce-eu-01-prod” is different with the key in my account setting ssh page. Then I am trying to add public SSH key to authorized_keys file. But looks like this file is read-only and I got message below when trying chmod:

chmod: changing permissions of ‘authorized_keys’: Read-only file system

My question is how can I add the public SSH key to ~/.ssh/authorized_keys ?




The authorized_keys file is a list of keys on a host that are allowed to SSH in. In other words, when you add your Cloud9 public key to GitHub, GitHub is putting that in their authorized_keys file to allow you to push from Cloud9 (it’s a little more advanced than that, but it’s the same concept). The problem here is simply that you need the correct access rights and the repository needs to exist (as in the error). Your authorized_keys file has nothing to do with this. Try the following steps:

  • Run ssh-keygen -lf ~/.ssh/, and make sure the output matches the Fingerprint of the Cloud9 key on GitHub.
  • Check to make sure that your repository exists, and confirm that the remote you have in git is of the format (you can see your git remotes using git remote -v
  • If your git remote is not in the above format, change it using git remote set-url


Yes you are right. I delete the old key on Github, regenerate the public key and use the new key on Github. Problem got resolved.
My repository is correct.

Thanks a lot for your help!