using bash git clone URL with ssh key, still get asked for password

Michael UGC Williams April 30, 2023

Screen Shot 2023-04-30 at 10.34.36 AM.png

2 answers

1 accepted

2 votes
Answer accepted
Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 1, 2023

Hi @Michael UGC Williams 

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

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

Michael UGC Williams May 4, 2023

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!

Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 4, 2023
0 votes
Michael UGC Williams April 30, 2023

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/'

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events