Home > Back-end >  Messed up with deploy key
Messed up with deploy key

Time:01-06

When I try to push my files to the git server I faced this problem. `~ git push fatal: The current branch main has no upstream branch. To push the current branch and set the remote as upstream, use

git push --set-upstream origin main

So, I've entered git push --set-upstream origin main in the terminal. It was showing up the following error.

ERROR: Permission to adivenkat05/C-Assignments.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.

So, after searching for the solution, it was that we need to upload our ssh key in the git server (Deploy Key).

I've uploaded that same key to another repository but it ended up showing me this "So, after searching for the solution, it was that we need to upload our ssh key in the git server (Deploy Key).

I've uploaded that same key to another repository but it ended up showing me this "Key is already in use".

So, it's not possible to have multiple ssh keys in a particular machine, right?

How do I tackle this problem?".

CodePudding user response:

The second error is different, and refer to an authentication problem.

You can have multiple keys, a deploy one and one associated with your user account.

Create a new dedicated key, and add it to your account:

ssh-keygen -t rsa -P "" -f ~/.ssh/me

Reference it in a ~/.ssh/config file:

Host gh
  Hostname github.com
  User git
  IdentityFile ~/.ssh/me
  IdentitiesOnly yes

And your SSH URL becomes gh:me/myRepository. (no more [email protected]:...) You can test your SSH key with ssh -Tv gh.

It it works:

cd /path/to/my/local/repo
git remote set-url origin gh:adivenkat05/C-Assignments.git
git push -u origin main
  • Related