DEV Community

Marcos Henrique
Marcos Henrique

Posted on

2 1

The safest way to download a private repository

Introduction πŸ•΅πŸ»β€β™€οΈπŸ•΅πŸ»

I'm writing a script to easily download a code stored in a private repository from the command line.
Many solutions to this was exposing credentials in the command line, personally, I didn't want to put my password into my script to accomplish this.

If you're the type to live dangerously and don't care about security, use the following:

curl --digest --user <username>:<password> https://bitbucket.org/<username>/<repository>/get/<branchname>.zip -o <branchname>.zip
Enter fullscreen mode Exit fullscreen mode

But if you're like me and care about the security of your applications, let's get down to business

Set up an SSH key πŸ‘©β€πŸ”§ πŸ‘¨β€πŸ”§

The first step is create private and public keys, I won't go into the details of how to do this, as we have the tutorials on github and bitbucket extramement explicit and clear on how to do this in the best way:

The magic command πŸ§™β€β™‚οΈπŸ§™β€β™€οΈ

I'll assume that you already have your keys configured, so just run the command below:

git archive --remote=ssh://git@bitbucket_or_github.org/your_username/your_repository.git --format=zip --output="zip_file.zip" desired_branch
Enter fullscreen mode Exit fullscreen mode

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❀️