Ricardo Castañeda
Ricardo Castañeda

Reputation: 5812

Permission denied to new ssh user when pushing

I'm using terminal, I want to delete ssh keys from and old user (old_username) and set a new one (new_username). I have done as is in this tutorial.

When I run: ssh -T [email protected] I get the correct message:

`Hi new_username! You've successfully authenticated'.


But when I try to push a repository I get denied:

remote: Permission to new_username/test2.git denied to old_username.
fatal: unable to access 'https://github.com/new_username/test2/': The requested URL returned error: 403

I've tried deleting .ssh folder and setting again ssh, but the problem persists.

Upvotes: 1

Views: 72

Answers (2)

VonC
VonC

Reputation: 1324318

Using an https url means your ssh connection is not used. At all.

Try switching to ssh:

git clone [email protected]:new_username/test2

That will actually use your ssh credentials, meaning your public and private keys stored in ~/.shh/id_rsa(.pub).

Upvotes: 1

piojo
piojo

Reputation: 6723

If on Linux or OSX, check a file called ~/.netrc, which contains username/password information that most apps will use when connecting to remote servers. Yes, it even affects git via the https protocol. If you're using a frontend to connect to github, you probably need to clear its preferences so it stops trying to use the old username.

Upvotes: 0

Related Questions