Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Auf dieser Seite wird beschrieben, wie Sie sich mit dem Credential Helper für den Managed Harbor Service (MHS) oder mit CLI-Secrets in Docker oder Helm anmelden.
Um Flexibilität zu bieten, bietet Google Distributed Cloud (GDC) Air-Gapped zwei Methoden zur Authentifizierung bei Docker und Helm über Ihre Harbor-Registry-Instanz. Bei der ersten Methode melden Sie sich mit dem Credential Helper für den Managed Harbor Service (MHS) und Ihrer GDC-Identität in der Docker- oder Helm-Befehlszeile an. Nach der Authentifizierung bei GDC können Sie sich im Docker-Client anmelden und Docker-Vorgänge ausführen, ohne separate CLI-Secrets in Harbor erstellen oder verwalten zu müssen.
Die zweite Methode verwendet CLI-Secrets. Nachdem Sie sich mit Identity-Aware Proxy (IAP) authentifiziert und sich zum ersten Mal in der Harbor-Benutzeroberfläche angemeldet haben, können Sie mit der Docker- oder Helm-Befehlszeile auf Harbor zugreifen. Die Docker- und Helm-Befehlszeilen können keine Weiterleitung für IAP verarbeiten. Daher stellt Harbor ein CLI-Secret bereit, das bei der Anmeldung über Docker oder Helm verwendet werden kann. Diese Methode ist nur verfügbar, wenn Harbor die IAP-Authentifizierung verwendet.
Hinweise
Um die Docker- und Helm-Authentifizierung für Harbor-Registry-Instanzen zu konfigurieren, benötigen Sie Folgendes:
Der MHS-Credential Helper docker-credential-mhs ist in der Umgebung installiert. Der Credential Helper ist standardmäßig im gcloud CLI-Bundle enthalten. Weitere Informationen finden Sie in der Übersicht über die gcloud CLI.
Die erforderliche Identitäts- und Zugriffsrolle. Bitten Sie Ihren Organisations-IAM-Administrator, Ihnen die Rolle „Harbor Instance Viewer“ (harbor-instance-viewer) zuzuweisen.
Mit Ihrer GDC-Identität bei Docker anmelden
Verwenden Sie den MHS Credential Helper mit Ihrer GDC-Identität, um sich in der Docker-Befehlszeile anzumelden. So authentifizieren Sie sich bei Docker:
Melden Sie sich mit der GDC CLI beim Management API-Server an. Folgen Sie dazu der Anleitung unter Anmelden.
Konfigurieren Sie Docker für die Verwendung des MHS Credential Helper docker-credential-mhs:
Optional: Prüfen Sie, ob der Anmeldedaten-Helper erfolgreich konfiguriert wurde, indem Sie prüfen, ob der Eintrag mhs zu ~/.docker/config.json hinzugefügt wurde:
catDOCKER_CONFIG_PATH
Ersetzen Sie DOCKER_CONFIG_PATH durch den Pfad zu Ihrer Docker-Konfigurationsdatei. Beispiel: ~/.docker/config.json.
# Push image
root@gpc-adhoc-70846130vm-bootstrapper-zone1:~# docker push ${REGISTRY}/harbor-project/nginx:latest
The push refers to repository [myinstance-e2e-test-user.org-1.zone1.google.gdch.test/harbor-project/nginx]
e4e9e9ad93c2: Pushed
6ac729401225: Pushed
8ce189049cb5: Pushed
296af1bd2844: Pushed
63d7ce983cd5: Pushed
b33db0c3c3a8: Pushed
98b5f35ea9d3: Pushed
latest: digest: sha256:7ba542bde95e6523a4b126f610553e3657b8108bc3175596ee7e911ae1219bfc size: 1778
# Pull image
root@gpc-adhoc-70846130vm-bootstrapper-zone1:~# docker pull ${REGISTRY}/harbor-project/nginx:latest
latest: Pulling from harbor-project/nginx
Digest: sha256:7ba542bde95e6523a4b126f610553e3657b8108bc3175596ee7e911ae1219bfc
Status: Image is up to date for myinstance-e2e-test-user.org-1.zone1.google.gdch.test/harbor-project/nginx:latest
Wenn der Vorgang nicht erfolgreich ist, wird möglicherweise die folgende Ausgabe angezeigt:
E1025 19:21:39.322290 1273587 get.go:24] failed to get user name: user is not logged in or login expired, please login again
In diesem Beispiel ist die GDC-Authentifizierungssitzung abgelaufen und Sie müssen sich noch einmal in GDC anmelden. Weitere Informationen finden Sie unter Anmelden.
Mit Ihrer GDC-Identität in Helm anmelden
Verwenden Sie den MHS Credential Helper mit Ihrer GDC-Identität, um sich in der Helm CLI anzumelden.
So authentifizieren Sie sich mit Helm:
Rufen Sie nach der Authentifizierung mit GDC Ihre Nutzeranmeldedaten vom Credential Helper ab:
Melden Sie sich mit den Anmeldedaten in der Helm-Befehlszeile an. Wenn Sie zur Eingabe der Anmeldedaten aufgefordert werden, verwenden Sie die vom Credential Helper zurückgegebenen Anmeldedaten.
Eine erfolgreiche Ausgabe für diesen Vorgang sieht so aus:
Login Succeeded
Mit CLI-Secrets bei Docker oder Helm anmelden
So melden Sie sich mit CLI-Secrets in Docker oder Helm an:
Melden Sie sich mit einem IAP-Nutzerkonto in Harbor an.
Klicken Sie auf Ihren Nutzernamen und wählen Sie Nutzerprofil aus.
Klicken Sie auf content_copyKopieren, um das mit Ihrem Konto verknüpfte CLI-Secret zu kopieren.
Optional: Wenn Sie Schaltflächen zum automatischen Generieren oder manuellen Erstellen eines neuen CLI-Secrets anzeigen möchten, klicken Sie in Ihrem Nutzerprofil auf das Dreipunkt-Menü more_horiz.
Wenn Sie ein neues CLI-Secret generiert haben, klicken Sie auf content_copyKopieren, um es zu kopieren.
Sie können Ihr CLI-Secret jetzt als Passwort verwenden, wenn Sie sich über die Docker- oder Helm-Befehlszeile in Harbor anmelden:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[[["\u003cp\u003eThis document outlines two methods for authenticating with Docker and Helm for Harbor registry instances within Google Distributed Cloud (GDC) air-gapped environments.\u003c/p\u003e\n"],["\u003cp\u003eThe first method involves using the Managed Harbor Service (MHS) credential helper along with your GDC identity, enabling direct sign-in to the Docker or Helm CLI without managing separate secrets.\u003c/p\u003e\n"],["\u003cp\u003eThe second method utilizes CLI secrets generated within the Harbor interface, which are necessary because Docker and Helm CLIs do not support Identity-Aware Proxy (IAP) redirection.\u003c/p\u003e\n"],["\u003cp\u003eTo use the MHS credential helper method, you must have the \u003ccode\u003edocker-credential-mhs\u003c/code\u003e installed and the Harbor Instance Viewer role, after which you can sign into docker and perform operations such as pushing and pulling images.\u003c/p\u003e\n"],["\u003cp\u003eCLI secrets, used in the alternative method, can be copied from the user profile section in Harbor and are non-expiring unless manually rotated.\u003c/p\u003e\n"]]],[],null,["# Sign in to Docker and Helm\n\nThis page describes how to sign in to Docker or Helm using the Managed Harbor Service (MHS) credential helper or CLI secrets.\n\nTo provide flexibility, Google Distributed Cloud (GDC) air-gapped provides two methods to authenticate with Docker and Helm from your Harbor registry instance. The first method is using the Managed Harbor Service (MHS) credential helper and your GDC identity to sign in to the Docker or Helm CLI. After authenticating with GDC, you can sign in to the Docker client and perform Docker operations, without having to create or manage separate CLI secrets in Harbor.\n\nThe second method is using CLI secrets. After you authenticate using Identity-Aware Proxy (IAP) and sign in to the Harbor interface for the first time, use the Docker or Helm CLI to access Harbor. The Docker and Helm CLIs cannot handle redirection for IAP, so Harbor provides a CLI secret to use when signing in from Docker or Helm. This method is only available when Harbor uses IAP authentication.\n\nBefore you begin\n----------------\n\nTo configure Docker and Helm authentication for Harbor registry instances, you must have the following:\n\n- The MHS credential helper `docker-credential-mhs` installed in the environment. The credential helper is included by default in the gdcloud CLI bundle. For more information, see [gdcloud CLI overview](/distributed-cloud/hosted/docs/latest/gdch/resources/gdcloud-overview).\n- The necessary identity and access role. Ask your Organization IAM Admin to grant you the Harbor Instance Viewer (`harbor-instance-viewer`) role.\n\nSign in to Docker with your GDC identity\n----------------------------------------\n\nUse the MHS credential helper with your GDC identity to sign into the Docker\nCLI. To authenticate with Docker, follow these steps:\n\n1. Sign in to the Management API server with GDC CLI by following the\n instructions in\n [Sign in](/distributed-cloud/hosted/docs/latest/gdch/platform/pa-user/iam/sign-in).\n\n2. Configure Docker to use the MHS credential helper `docker-credential-mhs`:\n\n TENANT_PROJECT=\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e\n HARBOR_INSTANCE_NAME=\u003cvar translate=\"no\"\u003eHARBOR_INSTANCE_NAME\u003c/var\u003e\n REGISTRY=$(kubectl get harborinstance $HARBOR_INSTANCE_NAME -n $TENANT_PROJECT -o jsonpath='{.status.url}' | sed s#https://##)\n\n docker-credential-mhs configure-docker --registries=${REGISTRY}\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e: the name of your tenant project. This is the same project name you provided when [creating your Harbor instance](/distributed-cloud/hosted/docs/latest/gdch/platform-application/pa-ao-operations/create-harbor-instances#create-a-harbor-registry-instance).\n - \u003cvar translate=\"no\"\u003eHARBOR_INSTANCE_NAME\u003c/var\u003e: the name of the Harbor instance that is created in [Create Harbor registry instances](/distributed-cloud/hosted/docs/latest/gdch/platform-application/pa-ao-operations/create-harbor-instances).\n3. Follow the instructions in\n [Configure Docker to trust the Harbor root CA](/distributed-cloud/hosted/docs/latest/gdch/platform-application/pa-ao-operations/configure-docker-trust#configure-docker-to-trust-harbor-root-ca).\n\n4. Optional: Verify that the credential helper is successfully configured\n by verifying the `mhs` entry is added to `~/.docker/config.json`:\n\n cat \u003cvar translate=\"no\"\u003eDOCKER_CONFIG_PATH\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eDOCKER_CONFIG_PATH\u003c/var\u003e with the path to your docker config file. For\n example, `~/.docker/config.json.`\n\n The output is similar to the following: \n\n {\n \"auths\": {\n \"10.200.0.1\": {\n \"auth\": \"YWRtaW46YWRtaW4=\"\n },\n \"10.200.16.5:10443\": {\n \"auth\": \"YWRtaW46ZEROVVJCVWE1a1FBcE4xQQ==\"\n }\n },\n \"credHelpers\": {\n \"asia.gcr.io\": \"gcloud\",\n \"eu.gcr.io\": \"gcloud\",\n \"gcr.io\": \"gcloud\",\n \"marketplace.gcr.io\": \"gcloud\",\n \"myinstance-e2e-test-user.org-1.zone1.google.gdch.test\": \"mhs\",\n \"staging-k8s.gcr.io\": \"gcloud\",\n \"us-central1-docker.pkg.dev\": \"gcloud\",\n \"us.gcr.io\": \"gcloud\"\n }\n }\n\n This example shows a successful output of `\"myinstance-e2e-test-user.org-1.zone1.google.gdch.test\": \"mhs\"`.\n5. Configure the tenant project in `gdcloud`:\n\n TENANT_PROJECT=\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e\n gdcloud config set project $TENANT_PROJECT\n\n The following output is shown: \n\n Updated property [core/project].\n\n6. Identify a Harbor project that you have management access to.\n [Create a Harbor project](/distributed-cloud/hosted/docs/latest/gdch/platform-application/pa-ao-operations/create-harbor-projects)\n if one does not exist.\n\n7. Perform Docker operations, such as an image push or pull:\n\n TENANT_PROJECT=\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e\n HARBOR_INSTANCE_NAME=\u003cvar translate=\"no\"\u003eHARBOR_INSTANCE_NAME\u003c/var\u003e\n REGISTRY=$(kubectl get harborinstance $HARBOR_INSTANCE_NAME -n $TENANT_PROJECT -o jsonpath='{.status.url}' | sed s#https://##)\n HARBOR_PROJECT=\u003cvar translate=\"no\"\u003eHARBOR_PROJECT_NAME\u003c/var\u003e\n\n # Push image\n docker pull nginx\n docker tag nginx ${REGISTRY}/${HARBOR_PROJECT}/nginx:latest\n docker push ${REGISTRY}/${HARBOR_PROJECT}/nginx:latest\n\n # Pull image\n docker pull ${REGISTRY}/${HARBOR_PROJECT}/nginx:latest\n\n A successful output is similar to the following: \n\n # Push image\n root@gpc-adhoc-70846130vm-bootstrapper-zone1:~# docker push ${REGISTRY}/harbor-project/nginx:latest\n The push refers to repository [myinstance-e2e-test-user.org-1.zone1.google.gdch.test/harbor-project/nginx]\n e4e9e9ad93c2: Pushed\n 6ac729401225: Pushed\n 8ce189049cb5: Pushed\n 296af1bd2844: Pushed\n 63d7ce983cd5: Pushed\n b33db0c3c3a8: Pushed\n 98b5f35ea9d3: Pushed\n latest: digest: sha256:7ba542bde95e6523a4b126f610553e3657b8108bc3175596ee7e911ae1219bfc size: 1778\n\n # Pull image\n root@gpc-adhoc-70846130vm-bootstrapper-zone1:~# docker pull ${REGISTRY}/harbor-project/nginx:latest\n latest: Pulling from harbor-project/nginx\n Digest: sha256:7ba542bde95e6523a4b126f610553e3657b8108bc3175596ee7e911ae1219bfc\n Status: Image is up to date for myinstance-e2e-test-user.org-1.zone1.google.gdch.test/harbor-project/nginx:latest\n\n If the operation is unsuccessful, you might see the following output: \n\n E1025 19:21:39.322290 1273587 get.go:24] failed to get user name: user is not logged in or login expired, please login again\n\n In this example, the GDC authentication session has expired and you must sign\n in to GDC again. For more information, see\n [Sign in](/distributed-cloud/hosted/docs/latest/gdch/platform/pa-user/iam/sign-in).\n\nSign into Helm with your GDC identity\n-------------------------------------\n\nUse the MHS credential helper with your GDC identity to sign into the Helm CLI.\n\nTo authenticate with Helm, follow these steps:\n\n1. After authenticating with GDC, retrieve your user credentials from the\n credential helper:\n\n echo $REGISTRY | docker-credential-mhs get\n\n The output is similar to the following: \n\n {\"Username\":\"tokenreview$fop-infrastructure-operator@example.com\",\"Secret\":\"STS-Bearer-3q2o6mBKk44Gzi4105vyiSnXMuixtnm-RnyxSgJtnYkNbGV7drpwgIuftinAXVlo0Im9kgoGmc2WcZTSjE-vh2a71Su7YjB6qIAjAQ5ABkY03AHNfkHhRZzxthumDIVAd08wm2weit3_NpMPgOnf9qMblds_Q0PAWk2OhpodBpCfyl3LWZpIZBaNVgtg-TB_7fjpEDOm-_Q5VYABScOgZFP_bw\"}\n\n2. Sign in to the Helm CLI with the credentials. When prompted to enter the\n credentials, use the credentials returned by the credential helper.\n\n helm registry login $REGISTRY\n Username: tokenreview$fop-infrastructure-operator@example.com\n Password: STS-Bearer-3q2o6mBKk44Gzi4105vyiSnXMuixtnm-RnyxSgJtnYkNbGV7drpwgIuftinAXVlo0Im9kgoGmc2WcZTSjE-vh2a71Su7YjB6qIAjAQ5ABkY03AHNfkHhRZzxthumDIVAd08wm2weit3_NpMPgOnf9qMblds_Q0PAWk2OhpodBpCfyl3LWZpIZBaNVgtg-TB_7fjpEDOm-_Q5VYABScOgZFP_bw\n\n A successful output for this operation looks like the following: \n\n Login Succeeded\n\nSign in to Docker or Helm with CLI secrets\n------------------------------------------\n\nTo sign in to Docker or Helm with CLI secrets, follow these steps:\n\n1. Sign in to Harbor with an IAP user account.\n2. Click your username and select **User Profile**.\n3. To copy the CLI secret associated with your account, click content_copy **Copy**.\n4. Optional: To display buttons for\n automatically generating or manually creating a new CLI secret, click the more_horiz ellipses in your user profile.\n\n | **Note:** A user can only have one CLI secret. When a new secret is generated or created, the old secret becomes invalid.\n5. If you generated a new CLI secret, click content_copy **Copy** to copy it.\n\n6. You can now use your CLI secret as the password when signing in to\n Harbor from the Docker or Helm CLI:\n\n docker login -u \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e -p \u003cvar translate=\"no\"\u003eCLI_SECRET\u003c/var\u003e \u003cvar translate=\"no\"\u003eHARBOR_INSTANCE_URL\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e: the Harbor account username\n- \u003cvar translate=\"no\"\u003eCLI_SECRET\u003c/var\u003e: the generated CLI secret.\n- \u003cvar translate=\"no\"\u003eHARBOR_INSTANCE_URL\u003c/var\u003e: the URL of the Harbor instance.\n\n| **Note:** The CLI secret does not expire, unless you manually rotate it. The CLI secret is not associated with the user identity token. Signing out from Harbor or the GDC console does not revoke the CLI secret."]]