Reputation: 12874
I'm facing the similar problem where I couldn't push the code to repo. So trying to access ~/.ssh
but it's not found?
I've also made sure that I've configured both user and email on global level as below
git config --global user.name "New Name"
git config --global user.email "New Email"
But when I try to push my code, it's still hitting permission denied? Where is this hidden ssh key?
Below is the exception that I'm getting
remote: Permission to newUser/testing.git denied to oldUserName. fatal: unable to access 'https://github.com/newUser/testing.git/': The requested URL returned error: 403
UPDATES:
When I run the command git remote -v
:
origin https://github.com/newUser/testing.git (fetch)
origin https://github.com/newUser/testing.git (push)
Upvotes: 0
Views: 1344
Reputation: 28454
You are using git over https, which has nothing to do with SSH.
Below are the steps to get the access to your repo over SSH:
Switch your repo from HTTPS to SSH:
git remote remove origin
git remote add origin [email protected]:newUser/testing.git
Generate new SSH key (unless you have one):
ssh-keygen -t rsa -b 4096 -C "[email protected]"
More detailed info is here.
Add new SSH key to your Github account:
Follow these steps.
Add following into ~/.ssh/config
:
Host github.com
User git
IdentityFile ~/.ssh/id_rsa
Enjoy
Upvotes: 2
Reputation: 2327
You are seeing this error because you are trying to push your changes to a repository you don't have access to. Check out the output of-
git remote -v
This should show you origin which points to your remote github account. If your URL is incorrect, you can set to the right location by-
git remote set-url origin <urltoyourremote>
Hope this helps.
Upvotes: 0