How do I correctly specify a custom `DRONE_REMOTE_URL` on clone step in my drone.yml?

I need to specify a custom DRONE_REMOTE_URL in my clone step in my drone.yml since enabling 2 step authentication for github. Unfortunately any attempts to pass in a custom value to my clone step have not worked and I keep getting:

fatal: could not read Username for 'https://github.com': No such device or address

Here is my drone.yml

pipeline:
  clone:
    image: plugins/git
    environment:
      - DRONE_REMOTE_URL="mycustomUrlWithGithubCreds@github.com/repoetc"

Am I passing in the variable correctly? I also attempted to set DRONE_REMOTE_URL as a secret and it doesn’t seem to be passing it in.

Am I passing in the variable correctly? I also attempted to set DRONE_REMOTE_URL as a secret and it doesn’t seem to be passing it in.

This is not possible and is not required. Drone will automatically authenticate using an oauth token when cloning a repository.

As an aside please note the clone configuration no longer resides in the pipeline section. See http://docs.drone.io/cloning/ for more information.

fatal: could not read Username for ‘https://github.com’: No such device or address

This error tells me one of the following:

  1. you added your repository when it was public, but then changed to private in github. Drone is unaware of this change and tries to clone without credentials
  2. the user account that added the repository to Drone revoked oauth access or was deleted, causing the clone authorization to fail
  3. you are running github in PRIVATE_MODE which requires authentication to clone public repositories and need to configure Drone accordingly

The above represent the most common issues people see. I can confirm cloning private repositories with GitHub works out of the box, and does not require any weird hacks to work.

Thanks for taking the time to reply. The only thing(s) that have changed since my clones started to fail was the fact that my github account joined an org that requires 2factor authentication. I have tried adding DRONE_GITHUB_PRIVATE_MODE=True to my dronerc file and recreating my drone server container to no avail (I kept my agent up and running and did not touch the drone.sql file).

2 is definitely not the case and I do not believe 1 to be at fault either, since newly created private repos cannot be cloned either… Would you recommend that I try to reinstall drone from scratch? (i.e. delete my drone.sql file?)

Even after reinstalling drone I am still getting the same error… My understanding of when 2factor authentication is enabled, cloning over https requires your password to be a personal authentication token (which I have set in dronerc file via DRONE_GITHUB_GIT_PASSWORD [is that completely unrelated to the clone step? Slightly confused as to what that is supposed to relate to]). Is there anyway to specify the clone step to connect via SSH instead of HTTPS?

drone uses oauth2 tokens to clone as described at https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth

I use 2factor authentication with github and can confirm it did not impact any of my drone installations or ability to clone, nor did it require any special configurations.

Thanks for you help. Just confirmed that I was doing something really stupid. Still not sure why drone suddenly stopped being able to clone private repos but I remember that I had tried to mount my /.ssh to drone in order to try a deploy step using a fab file: -v /$HOME/.ssh/id_rsa:/$HOME/.shh/id_rsa (I was blindly reusing this command from my history when starting my drone container). Omitting this allowed drone to correctly clone from private repos >.<