Reputation: 884
I'm looking for a way to download a file from bitbucket, (not the repository, a file from the download section). Currently, it is possible to clone a repository using a deployment key, but I couldn't make it work for downloads.
I have tried the following:
curl -u username: --key .ssh/id_rsa --pubkey .ssh/id_rsa.pub scp://bitbucket.org/repositoryowner/downloads/downloadfile.zip
EDIT:
The current best workaround is to create a throw-away dummy user:
wget -O /tmp/file --user "username" --password "password" https://bitbucket.org/owner/rep/downloads/abc.tar.gz
Upvotes: 14
Views: 5443
Reputation: 37
App password is another official workaround which works well.
First, you must generate an app password, here is the guide: https://support.atlassian.com/bitbucket-cloud/docs/create-an-app-password/
Then you can run a curl command:
curl --user {bitbucket_username}:{app_password} -L -O https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/downloads/{filename}
Upvotes: 0
Reputation: 7349
After a bunch of failed attempts, I received this response from Bitbucket support:
Access keys in Bitbucket Cloud can be used for cloning or pulling from a repository only, I'm afraid it is not possible to download files from the Downloads section of the repo with SSH keys.
Unless the repository is public, users will need to have a Bitbucket Cloud account in order to authenticate and download files from the Downloads page.
Feel free to let us know if you have any further questions.
This has now been made a feature request on Bitbucket. If you want to have this functionality, then upvote it:
https://bitbucket.org/site/master/issues/18501
Upvotes: 8