using bash git clone URL with ssh key, still get asked for password
Asked by Michael UGC Williams:

![Screen Shot 2023-04-30 at 10.34.36 AM.png](/t5/image/serverpage/image-id/254628i3462B91D919C6D49/image-size/large?v=v2&px=999 "Screen Shot 2023-04-30 at 10.34.36 AM.png")


Answers:
author: Erez Maadani
body: Hi [@Michael UGC Williams](/t5/user/viewprofilepage/user-id/5208035)

The URL you are using seems to be an HTTPS URL and not SSH.

Your SSH URL should like this: [git@bitbucket.org/ultimategamingchampionship/website.git](https://git@bitbucket.org/ultimategamingchampionship/website.git)

or like: <ssh://git@bitbucket.org/ultimategamingchampionship/website.git>

comments: author: Michael UGC Williams
body: Hi Erez,

Thank you. Where did you find the reference on how to construct the SSH URL? Your first suggestion works, the second one does not. Any ideas why ?

Many thanks!


author: Erez Maadani
body: Hi [@Michael UGC Williams](/t5/user/viewprofilepage/user-id/5208035)

Have a look here: <https://support.atlassian.com/bitbucket-cloud/docs/change-the-remote-url-to-your-repository/>


author: Michael UGC Williams
body: Hi I'm on MacOS Monterey, using bash to run git clone to clone a repo. I've created a private/public keypair of ssh keys for this purpose. I installed the .pub key into my Personal Settings on Bitbucket.org.

--

I followed this guide to setup ssh keys for bitbucket on my local Mac: <https://support.atlassian.com/bitbucket-cloud/docs/set-up-personal-ssh-keys-on-macos/>

--

Ssh version is:

ssh -V

OpenSSH_8.6p1, LibreSSL 3.3.6

--

My .ssh/config file has:

ServerAliveInterval 90

Host bitbucket.org

AddKeysToAgent yes

PreferredAuthentications publickey

IdentityFile \~/.ssh/\<keyname\>

--

When I use this URL (what I think is the SSH URL) I get this output:

Michaels-Mac-Pro:UGC code, assets MGW$ GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git clone <https://git@bitbucket.org/ultimategamingchampionship/website.git>

10:30:39.891919 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/bin/git

10:30:39.892569 exec-cmd.c:238 trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/bin

10:30:39.892882 git.c:460 trace: built-in: git clone <https://git@bitbucket.org/ultimategamingchampionship/website.git>

Cloning into 'website'...

10:30:40.172016 run-command.c:654 trace: run_command: git remote-https origin <https://git@bitbucket.org/>\<workspace\>/website.git

10:30:40.177111 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git

10:30:40.177698 exec-cmd.c:238 trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core

10:30:40.178239 git.c:749 trace: exec: git-remote-https origin <https://git@bitbucket.org/>\<workspace\>/website.git

10:30:40.178265 run-command.c:654 trace: run_command: git-remote-https origin <https://git@bitbucket.org/>\<workspace\>/website.git

10:30:40.182849 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-remote-https

10:30:40.183364 exec-cmd.c:238 trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core

10:30:40.602217 run-command.c:654 trace: run_command: 'git credential-osxkeychain get'

10:30:40.611189 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git

10:30:40.611831 exec-cmd.c:238 trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core

10:30:40.612383 git.c:749 trace: exec: git-credential-osxkeychain get

10:30:40.612404 run-command.c:654 trace: run_command: git-credential-osxkeychain get

Password for '<https://git@bitbucket.org>':

--

When I try the HTTPS clone URL I get:

Michaels-Mac-Pro:UGC code, assets MGW$ GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git clone <https://gwhizofugc@bitbucket.org/>\<workspace\>/website.git

10:43:44.044604 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/bin/git

10:43:44.045203 exec-cmd.c:238 trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/bin

10:43:44.045703 git.c:460 trace: built-in: git clone <https://gwhizofugc@bitbucket.org/>\<workspace\>/website.git

Cloning into 'website'...

10:43:44.610387 run-command.c:654 trace: run_command: git remote-https origin <https://gwhizofugc@bitbucket.org/>\<workspace\>/website.git

10:43:44.615415 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git

10:43:44.616041 exec-cmd.c:238 trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core

10:43:44.616577 git.c:749 trace: exec: git-remote-https origin <https://gwhizofugc@bitbucket.org/>\<workspace\>/website.git

10:43:44.616601 run-command.c:654 trace: run_command: git-remote-https origin <https://gwhizofugc@bitbucket.org/>\<workspace\>/website.git

10:43:44.622374 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-remote-https

10:43:44.622924 exec-cmd.c:238 trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core

10:43:45.024435 run-command.c:654 trace: run_command: 'git credential-osxkeychain get'

10:43:45.044009 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git

10:43:45.044639 exec-cmd.c:238 trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core

10:43:45.045211 git.c:749 trace: exec: git-credential-osxkeychain get

10:43:45.045233 run-command.c:654 trace: run_command: git-credential-osxkeychain get

Password for '<https://gwhizofugc@bitbucket.org>':

--

If I run:

ssh -T git@bitbucket.org

authenticated via ssh key.

You can use git to connect to Bitbucket. Shell access is disabled

--

I don't think I should need to enter any passwords. If I enter the password anyway to the above prompt, I get:

10:45:56.463192 run-command.c:654 trace: run_command: 'git credential-osxkeychain erase'

10:45:56.472239 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git

10:45:56.472858 exec-cmd.c:238 trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core

10:45:56.473356 git.c:749 trace: exec: git-credential-osxkeychain erase

10:45:56.473375 run-command.c:654 trace: run_command: git-credential-osxkeychain erase

remote: Login failed due to incorrect login credentials or method.

remote: If you are unsure of which login details or login method to use, visit:

remote: <https://support.atlassian.com/bitbucket-cloud/docs/log-into-or-connect-to-bitbucket-cloud/>

fatal: Authentication failed for '<https://bitbucket.org/ultimategamingchampionship/website.git/>'


Tags: bitbucket-cloud

cloud

ssh-key