Reputation: 3919
I just generated an SSH key and added it to my ssh-agent in a Linux Mint terminal. I then copied the content of the .pub
file and pasted into the GitHub user-wide SSH key box. I call git pull
and it works. I call add
and commit
and everything seems fine.
But then I call git push -u origin main
and I get
ERROR: Permission to name/repo.git denied to deploy key
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Upvotes: 1
Views: 1991
Reputation: 52
Specifically they say add the following to ~/.ssh/config
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
https://stackoverflow.com/a/43054414/6521970
Upvotes: -1
Reputation: 76409
When you uploaded the public key you generated to GitHub, you put it in the per-repository deploy key box. Deploy keys are SSH keys designed to operate on a single repository, and they are read-only by default. You have to check the box when you add the public key if you want the key to be read-write. That's because in many cases, deploy keys are used only to deploy code, and so it's better not to grant them access they don't need. They can also be used for other machine operations, though, so write access is available.
Since you've already uploaded it, you'll have to delete the deploy key from GitHub and re-add it, since there's no way to change the settings for an existing key. When you re-add it, check the checkbox that says, “Allow write access.”
If you had intended this to work for your entire user account instead of just this particular repository, then you'll need to remove the deploy key entry and upload it instead in your user settings. You have to remove the deploy key entry first because the same key can only be used for one purpose, and the key identifies the actor (user or deploy key) and permissions.
Upvotes: 4