19

I am having troubles when I connect with my repository through Xcode.

I have a Gitlab version (full pre-)installed on TurnkeyLinux Virtual Appliance on a remote server. In the Gitlab Web interface, I've created a new test user: "testuser" with a password "password" and a new project "testproject". This user was assigned to this project.

The git url project are:

HTTP: http://example.com/testuser/testproject.git
SSH: git@example.com:testuser/testproject.git

I can see the repositories folder rightly created with a "Terminal" through SSH connection.

Now, I want add this git repository to my Xcode repositories.

So, In

XCode > Preferences > Account     

I'm trying add it, using both urls and my user credentials, but always receive the following message:

"Authentication failed because the name or password was incorrect."

Could anyone help me?

Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
mzurita
  • 690
  • 1
  • 14
  • 33

6 Answers6

30

The user/password would only be needed for an http url, not an ssh one.

When using the http url to add a repo in your XCode Accounts, make sure there is no proxy which would prevent the resolution of the example.com server.

If it is still not working, then, as in "Authentification issue when pushing Xcode project to GitHub", try to use an url like:

https://testuser:password@example.com/testuser/testproject.git
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 3
    Adding the username:password to the URL worked for me. – Peter Gluck May 27 '14 at 17:23
  • I had the same issue and even simply including the username in the url worked. Use `https://testuser@mydomain.com/testuser/testproject.git` and then it will ask for password. I think there is an error when you try to enter the username (when you enter username and go to the password field, the username field becomes empty) – golddove Aug 05 '14 at 04:08
  • 1
    I saw the same issue as golddove today and your syntax resolved the issue. Rhetorically, I'd like to know why I needed to use Stackoverflow for this versus Xcode getting their act together?? – LevinsonTechnologies Aug 18 '15 at 18:15
  • We are in 2020 and this is still happening! This is the only thing that works – Brett Jun 11 '20 at 08:12
  • @Brett Maybe https://github.com/microsoft/Git-Credential-Manager-for-Mac-and-Linux can help and avoid an URL with username:password in it. – VonC Jun 11 '20 at 08:24
  • Thanks @VonC I use Sourcetree mostly, I was just trying to add a Swift Package and kept running into this issue. I normally would never use a password in a URL :-) – Brett Jun 11 '20 at 08:30
3

Even if the problems seems solved I've found this question when I had the problem using XCode 10. I tried logging in to GitHub and got the same error. The workaround described didn't fix my problem but I've found another solution on my own which I'd like to share – maybe it helps somebody ;)

My GitHub password included an 'ä' character (I'm German) and seems XCode and GitHub don't support the used encoding. After changing my password to something without an 'ä' it worked fine. Maybe it wasn't because of the 'ä' but it already helped to change the password - I don't know.

Pinolpier
  • 467
  • 4
  • 13
2

Thank you, but the reasons are Xcode seems a little crazy…

In

Xcode > Source Control > Test Project (master) > Configure Test Project…

I've just added my repository HTTP URL and credentials were not needed, and when I trying push/pull actions Xcode ask me for user/password.

Seems to be Repository in Preferences > Account doesn't work fine…

mzurita
  • 690
  • 1
  • 14
  • 33
  • 1
    I find this to be true for me as well. I am not sure why xcode wants my u/p for gitlab all of a sudden, but it didn't before upgrading to 7. – zeeple Sep 28 '15 at 02:35
1

you'd better use the project configuration:
‘Source Control’ > ’(project name)-Master’ > ‘Configure (project name)’,
select ‘Remote’, choose ‘+’ > Add Remote
 Name : origin
 Address : git@gitlab.com:xxx/yyy.git
(Curiously it appears after this in the XCode prefs)

Don't forget: using SSH, the password is the one you used (keygen) when building the key !

tontonCD
  • 320
  • 2
  • 6
0

I don't want to use HTTP! Key file under "git" user is very convenient and secure, I'm not going to type my password in a unencrypted URL entry in some plist file.

In my case, the problem was that Xcode was trying to use the wrong key file :

.ssh/id_rsa
instead of
.ssh/id_dsa
Yann Bizeul
  • 403
  • 3
  • 10
0

Here using Xcode 7.3.1 and finally managed to push using ssh (and Gogs as github server) by doing so:

1) select the correct private key (there must also be the public key file present)

on Gogs side:

2) add that same key from the Gogs user Settings->SSH Keys

3) under admin panel: Dashboard: Operations: rewrite the authorised_keys file

Done