angel_30
angel_30

Reputation: 1

Unable to clone repository from Gitlab: Permission denied, please try again

I'm trying to clone an empty repository from my Gitlab account. I simply use the address shown on my Gitlab repository page under SSH:

[email protected]:USERNAME/project-name.git

enter image description here

Then simply try this in an empty folder, but it keeps telling me permission denided, asking for retry:

git clone [email protected]:USERNAME/project-name.git
Cloning into 'project-name'...
[email protected]'s password:
Permission denied, please try again.
[email protected]'s password:

and when I choose the https address for clone, this is the message:

remote: HTTP Basic: Access denied
fatal: Authentication failed for ....

I am able to login to Gitlab homepage with that password, so I don't know what is really wrong.

What is wrong? How to fix it?

Upvotes: 10

Views: 46754

Answers (4)

Brian W.
Brian W.

Reputation: 150

I had this problem when trying to clone a repo locally using the SSH link from the Gitlab UI. On my server I'm running Gitlab in Docker, accessible on the host via port 9022 (which maps to port 22 in the Gitlab container).

I added the following to the Gitlab config and now the UI link displays correctly and works for cloning:

gitlab_rails['gitlab_shell_ssh_port'] = 9022

Upvotes: 0

CtC
CtC

Reputation: 64

What finally worked for me was to use:

$ git clone ssh://[email protected]:2022/USERNAME/project-name.git

I'll break this down as there are a three parts here:

  1. It was critical to specify "ssh://" and change ":USERNAME" to "/USERNAME".
  2. I do not have a hostname configured for this machine, so I used the IP Address.
  3. I'm running GitLab in a docker container and port 22 is forwarded via port 2022.

In summary, GitLab suggests this format:

[email protected]:USERNAME/project-name.git

which results in:

Permission denied, please try again.

regardless of whether the correct password is entered or a password is even set. Instead, the following format works:

ssh://[email protected]/USERNAME/project-name.git

GLHF!

Upvotes: 1

angel_30
angel_30

Reputation: 1

As I'm in Windows, this answer was the life saver:

It happen every time I'm forced to change the Windows password and none of above answers helped to me.

Try below solution which works for me:

Go to Windows Credential Manager (press Windows Key and type credential) to edit the git entry under Windows Credentials. Replace old password with the new one.

Upvotes: 6

ErniBrown
ErniBrown

Reputation: 1372

ssh authentication on Gitlab requires a ssh key. You need to generate one, depending on your host, windows, linux or other. Then you need to add the key to your account.

You can find all the required information here: https://gitlab.com/help/ssh/README.md

If you want to use your http login you should switch to http authentication. At the left of the repository address there's a menu, you can choose ssh or http. Use the latter

Upvotes: 3

Related Questions