4

I cannot clone the project although

ssh -T git@gitlab.com

shows what I want: Welcome to GitLab, @vagnerwentz!.

The error during cloning:

Cloning into 'jobfygo'...
Username for 'https://gitlab.com': vagnerwentz
Password for 'https://vagnerwentz@gitlab.com': 
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.com/jobfy/backend/jobfygo.git/'
questionto42
  • 7,175
  • 4
  • 57
  • 90
Vagner Wentz
  • 391
  • 1
  • 7
  • 29

2 Answers2

2

First, you are cloning with an HTTPS URL, which means all your SSH settings is for naught.

Second, regarding HTTPS, double-check if you have 2FA activated, because if you do, your password would actually be a PAT (Personal Access Token)

Third, if you do want to use SSH, then use the SSH URL:

git@gitlab.com:jobfy/backend/jobfygo.git

By default, such an url would use the default private SSH key ~/.ssh/id_rsa. So if you have a key with another name, you would need to:

  • either rename it to id_rsa
  • specify it directly ssh -i /path/to/second/private/key
  • use a ~/.ssh/config file
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • If your project is not directly on the gitlab.com domain, but something like `https://git.mysuborga.myorga.com/projectowner/myproject.git`, use `git clone git@git.mysuborga.myorga.com:projectowner/myproject.git`. – questionto42 Feb 17 '21 at 18:44
2

I resolved changing the SSH Key to RSA Key.

Vagner Wentz
  • 391
  • 1
  • 7
  • 29
  • But you also have changed the URL as I mentioned in my answer, right? Even a rsa key would not work with an HTTPS URL. – VonC May 13 '20 at 17:19
  • I have two accounts at Gitlab with differents email (obvious hahaha) and the first account I generated the SSH Key and the other account I generated the RSA Key with SSH Key, so I searched the files I created with different names the first account it's rsa.pub... and the other it's jobby, the name of files. – Vagner Wentz May 13 '20 at 17:23
  • What do you mean by "changing"? Do you mean "renaming", or did you make a new key pair with rsa? Because when I copy the "id_ed25519" and rename it to "id_rsa", it says: "WARNING: UNPROTECTED PRIVATE KEY FILE! Permissions are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored." Thus, do I have to make a new key pair using rsa then? – questionto42 Feb 17 '21 at 16:54
  • @questionto42 Your warning/error is only about read/write access, not about key type. Simply chmod 600 the file, and the error is gone. Regarding renaming, it could be converting from OpenSSH to PEM/RSA: I did the opposite this morning (https://stackoverflow.com/a/66237922/6309). Or it was regenerating a new RSA key. – VonC Feb 17 '21 at 19:10
  • @VonC yes you are right, if you regenerate the rsa key pair, the warning/error is gone, and chmod 600 might have done so as well (untested). – questionto42 Feb 17 '21 at 19:17
  • This answer did not help me: it does not solve the problem of the authentification failure. If you use the HTTPS URL, it will throw that error (this holds even if you embed the SSH in the HTTPS like in `https://git@gitlab.com/jobfy/backend/jobfygo.git`), while with SSH URL (and ssh -i), I could clone (without username or pw !!) with private key id_ed25519 in ~/.ssh, no change to RSA needed (neither renaming nor making a new key pair). The wrong thing was that I did not know how to build the SSH URL, see the comment under @VonC's answer that should be accepted. – questionto42 Feb 17 '21 at 19:24