Isaac
Isaac

Reputation: 12874

Trying to remove old SSH key but couldn't find it?

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

Answers (2)

Andrejs Cainikovs
Andrejs Cainikovs

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:

  1. Switch your repo from HTTPS to SSH:

    git remote remove origin
    git remote add origin [email protected]:newUser/testing.git
    
  2. Generate new SSH key (unless you have one):

    ssh-keygen -t rsa -b 4096 -C "[email protected]"
    

    More detailed info is here.

  3. Add new SSH key to your Github account:

    Follow these steps.

  4. Add following into ~/.ssh/config:

    Host github.com
      User git
      IdentityFile ~/.ssh/id_rsa
    
  5. Enjoy

Upvotes: 2

priteshbaviskar
priteshbaviskar

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

Related Questions