hub-tool icon indicating copy to clipboard operation
hub-tool copied to clipboard

Add the ability to pass token/password to hub-tool using CLI switches or environment vars

Open slmingol opened this issue 3 years ago • 3 comments

Description Add the ability to pass token/password to hub-tool using CLI switches or environment vars. Other CLI's like docker do this for comparison.

$ hub-tool/hub-tool login <user> --password-stdin <<<$(echo "password")

Do something similar with LastPass's CLI

$ docker login -u $(lpass show --username 'dockeruser') --password-stdin <<<$(lpass show --password 'dockerpass')

References

  • https://docs.docker.com/engine/reference/commandline/login/

slmingol avatar May 12 '21 13:05 slmingol

I tried this (very hacky) workaround (I'm using ubuntu-latest on my GitHub Actions runner):

          /usr/bin/expect <(cat << EOF
          spawn /tmp/hub-tool login ${{ secrets.DOCKERHUB_USERNAME }}
          expect "\033\[0;34mPassword: \033\[0m"
          send "${{ secrets.DOCKERHUB_TOKEN }}\n"
          interact
          EOF
          )

But it's failing, most likely due to "Password: " being printed with colors. I tested locally and this WORKS on my machine even without the ANSI colors codes, but not on GitHub Actions' runner. :-(

rsaffi avatar Jul 13 '21 20:07 rsaffi

What I ended up doing, for now (but sucessfully): built the ~/.docker/config.json by hand. For the JWT token, I get it with a cURL request directly to the API. 🤷🏻‍♂️ Then I can use hub-tool, as it's much easier than talking to the API directly.

rsaffi avatar Jul 14 '21 06:07 rsaffi

I have a patch for this in https://github.com/docker/hub-tool/pull/198 which enables providing the Docker Hub password using the DOCKER_PASSWORD environment variable.

c-w avatar Jan 03 '22 20:01 c-w