Swift Package Manager and Xcode SSH authentication not working

On Xcode 15 running on Sonoma 14.2.1 attempting to add a package through SPM for a private repo hosted on Bitbucket is failing. (The issue has been experienced o Xcode 14 as well). On attempting to authenticate a new client Xcode is directing to login through Account and Password ignoring the SSH key.

This issue is only affecting new clients. For existing clients this method of authentication continues to work.

I'm following the steps here: https://support.atlassian.com/bitbucket-cloud/docs/set-up-personal-ssh-keys-on-macos/

Specifically:

Create an SSH key pair ssh-keygen -t ed25519 -b 4096 -C "{username@emaildomain.com}" -f {ssh-key-name} Or sh-keygen -t rsa -b 2048 -C "{username@emaildomain.com}" -f {ssh-key-name}

Add your key to the SSH agent

ssh-add ~/{ssh-key-name}

Update and check correct SSH configuration.

~/.ssh/config Such as: Host bitbucket.org AddKeysToAgent yes IdentityFile ~/.ssh/{ssh-key-name}

The key is then added as an Access Key to the repository on Bitbucket.

Check that your SSH authentication works ssh -T git@bitbucket.org

In then get the reponse: authenticated via ssh key. You can use git to connect to Bitbucket. Shell access is disabled

Which Indicates that SSH can successfully connect with Bitbucket using the SSH key. I'm also able to Git clone, push, pull through terminal.

But in Xcode, after adding a package dependency through "Add Package Dependency and enter its repository URL" The following dialog appears.

On clicking Trust Xcode then will continue to ask for login through Account and Password.

I have tried

Quit Xcode if it's still running
If still needed, fix your ssh problem (e.g. add your public key to the remote user's .ssh/authorized_keys).
Test git in a shell (not in Xcode). E.g. "cd /tmp ; git clone ssh://.../path/repo.git"
(in Terminal...)
$ defaults delete com.apple.dt.xcode IDESourceControlKnownSSHHostsDefaultsKey
$ sudo killall ssh-agent
start Xcode and attempt to clone a project into a temporary directory using your ssh://... URL
 Open the original project which was causing grief in Xcode, and could successfully pull, fetch, whatever.

But this did not resolve the issue

Try adding the following lines to you /etc/ssh/ssh_config file... beware, use sublime, vim, VS Code or any other text editor except TextEdiit as it won't let you change the file... you will be asked for a administrator password (usually your account) when saving...

HostkeyAlgorithms +ssh-rsa PubkeyAcceptedAlgorithms +ssh-rsa

Swift Package Manager and Xcode SSH authentication not working
 
 
Q