bashsingle-sign-onwget

Download file from TeamCity with SSO using bash


I need to download an artefact from TC using a bash command (it should work in Ubuntu 22.04.3 deb based server). TeamCity authentication mode is SSO only via MS account and 2FA authentication. Is it possible somehow to wget my TC builds?

I tried

wget --user my_username --ask-password -v --load-cookies 2sso.cookie --save-cookies auth2.cookie --keep-session-cookies https://teamcity***.iso

but got

Resolving teamcity***.com (teamcity***.com)... 1.2.3.4
Connecting to teamcity***.com (teamcity***.com)|1.2.3.4|:443... connected.
HTTP request sent, awaiting response... 401

Username/Password Authentication Failed.

In this command, user is my MS account.


Solution

  • First access token needs to be crated in your Team City user profile. Then curl might be used to download artifacts.

    curl -H "Authorization: Bearer <bearer token here>" <Team City file link> > ~/<file name to save>