1

I need to clone a GitLab (custom instance) repository from a script using an authentication (or deploy) token.

I've seen and tried Using GitLab token to clone without authentication (and others) for how to do that with an https URL scheme, but this GitLab instance has http access disabled.

How to use the authentication token with an ssh URL? I can't seem to find any example, even in the official documentation.

1 Answer 1

3

you can not use a token to clone via ssh, what you need is an SSH-key.

There are a few ways you can achieve this:

  1. either use your own key (not recommended)
  2. create a Deploy key (Settings -> Repository -> Deploy Key)

To use a custom key within a script you can take a look at How to specify the private SSH-key to use when executing shell command on Git? - which explains different ways of setting a custom ssh key for the checkout.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. That's what I also thought, but here and there in the documentation they seem to imply that it is possible without saying how, like if it was obvious. I'm going to try your solution. (Of course, option 1 is for me a no go, and the reason why I want to use tokens, or at least a key that gives only read-only rights).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.