DEV Community


The safest way to download a private repository

wakeupmh profile image Marcos Henrique ・1 min read

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><username>/<repository>/get/<branchname>.zip -o <branchname>.zip

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:// --format=zip --output="" desired_branch


Editor guide