Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,295,853
Community Members
 
Community Events
165
Community Groups

How do I configure crontab to git push with SSH-keys?

I have a script that automatically adds, commits and pushes to Bitbucket. It runs as expected and it backs up my Obsidian folder containing markdown files.

I want to run this script through crontab but I don't fully succeed. Adding and committing works as expected, but when I try to connect to Bitbucket I get:

fatal: could not read Password for 'https://---@bitbucket.org': Device not configured

 It seems to me that cron can't access my credentials. Now, I am not sure how to tackle this as I am not 100% sure how the credentials are handled...  When I was setting up my credentials I followed this guide (for MacOS): https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

With that background: how do I tell, either in crontab or my script, to use the credentials (that I think are stored in my keychain).

Help is much appreciated!

 

 

1 answer

0 votes

Hi Jonas,

If you want to use SSH for interacting with Bitbucket repos, apart from setting up SSH keys, you'll also need to use the SSH URL for the repo.

Based on the error that you get, it looks that you're using an HTTPS URL instead, https://---@bitbucket.org

If you specify the URL in your script, you'll need to replace the URL in the script from HTTPS to the SSH one, which has the format

git@bitbucket.org:<workspace-id>/<repo-slug>.git

If you don't specify the URL in your script, I assume that the script is using the URL defined for the clone of this repo on your machine, so you'll need to change that.

If you navigate to the clone directory from a terminal on this machine, you can run

git remote -v

and the output should look as follows:

origin https://<Bitbucket_username>@bitbucket.org/<workspace-id>/<repo-slug>.git (fetch)
origin https://<Bitbucket_username>@bitbucket.org/<workspace-id>/<repo-slug>.git (push)

You can change that URL to an SSH one with the command

git remote set-url origin git@bitbucket.org:<workspace-id>/<repo-slug>.git

If your remote name is different than 'origin', replace 'origin' with your remote name.
<workspace-id> should be replaced with the workspace id of the workspace that owns this repo
<repo-slug> should be replaced with the repository slug

Please feel free to let me know if you have any questions.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,170 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you