Pietro
Pietro

Reputation: 13220

git: cannot push on GitLab

I created a repository on GitLab and I have a local project.

From: git remote -v I get:

origin  [email protected]:projects/MyPrj.git (fetch)
origin  [email protected]:projects/MyPrj.git (push)

When I try to push it to the repository with:

git push origin master

I get this error:

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I can access the repository with a web browser, but not from git from the command line.

What am I doing wrong?

Upvotes: 0

Views: 4849

Answers (1)

VonC
VonC

Reputation: 1328602

Check what is your remote URL associated with your local cloned repo:

cd /path/to/your/repo
git remote -v 

Depending on its scheme (https or ssh), you will need to make sure your authentication is correctly set.

  • https: you will need to enter your credentials once in order to cache them in the git credential helper (check what git config credential.helper returns)
  • ssh: make sure you have a /path/to/home/.ssh/id_rsa(.pub) files (public and private rsa SSH keys, with the public key content registered on your remote hosting service.

If this is SSH (on Linux), you need to follow "GitLab and SSH keys " and generate a new set of SSH keys with:

ssh-keygen -P "" -s -t rsa

Then copy the ~/.ssh/id_rsa.pub content on GitLab.

Upvotes: 2

Related Questions