Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Hier erfahren Sie, wie Sie einen SSH-Tunnel von Ihrem lokalen Computer zu einer Workstation öffnen und dann mithilfe der VS Code-Remote-Entwicklung eine Verbindung von Ihrem lokalen VS Code-Editor zu Cloud Workstations herstellen.
Hinweise
Führen Sie die folgenden Schritte aus, bevor Sie beginnen:
Wenn Sie die gcloud CLI zum ersten Mal ausführen, müssen Sie möglicherweise auch gcloud auth login ausführen, um Anmeldedaten abzurufen, und gcloud config set project PROJECT_ID, um Ihr aktuelles Projekt auf die Projekt-ID festzulegen, die Sie im vorherigen Schritt kopiert haben.
Wenn Sie ssh zum ersten Mal verwenden, installieren Sie eine Remote-SSH-Erweiterung, damit Sie über den Extension Marketplace oder die Befehlspalette eine Verbindung vom VS Code-Editor zu einer Workstation herstellen können.
Extensions Marketplace
Öffnen Sie den lokalen VS Code-Editor und dann den Extension Marketplace. Wählen Sie dazu in der Aktivitätsleiste Erweiterungen aus.
Klicken Sie auf Installieren, um die Erweiterung Remote – SSH zu installieren.
Geben Sie remote ssh in das Suchfeld ein. Daraufhin wird die Erweiterungsseite für Remote – SSH geöffnet.
Befehlspalette
Drücken Sie zum Öffnen der Befehlspalette Strg + Umschalt + P (oder Befehl + Umschalt + P unter macOS) oder klicken Sie auf Ansicht>Befehlspalette.
Geben Sie ext install ms-vscode-remote.remote-ssh ein, um die Erweiterung zu installieren.
Klicken Sie auf den Namen der Workstation, um die Seite Workstation-Details zu öffnen.
Ersetzen Sie im folgenden Beispiel die Platzhalter für den Namen der Workstation, die Region (Standort), den Namen des Workstation-Clusters und den Namen der Workstation-Konfiguration. Kopieren Sie die Werte aus dem Bereich „Workstation-Details“ in die Platzhalter, die mit dem Symbol Bearbeiten gekennzeichnet sind.
Die Projekt-ID finden Sie im Abschnitt Vorbereitung.
Das Flag --local-host-port=:LOCAL_PORT ist optional.
Wenn Sie einen lokalen Port angeben möchten, ersetzen Sie LOCAL_PORT durch die gewünschte lokale Portnummer. Wenn Sie keinen lokalen Port angeben, wählt das System einen beliebigen, nicht verwendeten lokalen Port für Sie aus und gibt eine Meldung mit der Portnummer aus, damit Sie wissen, welcher lokale Port verwendet wird.
Nachdem Sie die Platzhalter ausgefüllt haben, klicken Sie auf content_copyCodebeispiel kopieren, um den gcloud-Befehl zu kopieren.
Fügen Sie den Befehl in das lokale Terminalfenster ein und drücken Sie die Eingabetaste, um den Tunnel zu erstellen.
Wenn der Befehl erfolgreich war, wird die Meldung Listening on port gefolgt von der lokalen Portnummer angezeigt.
Weitere Informationen zu den einzelnen Konfigurationsflags finden Sie unter SSH-Tunnel oder start-tcp-tunnel.
Verbindung zu einem Cloud Workstations-Host herstellen
So stellen Sie eine Verbindung zu einem Cloud Workstations-Host her:
Öffnen Sie die VS Code-Anwendung oder kehren Sie zu ihr zurück.
Klicken Sie in der Statusleiste auf Remote-Fenster öffnen, um Remote – SSH zu starten.
Wählen Sie in der Befehlspalette die Option Mit Host verbinden aus.
Geben Sie user@localhost:LOCAL_PORT ein und ersetzen Sie dabei LOCAL_PORT durch Ihre lokale Portnummer.
Im folgenden Beispiel wird durch Angabe von user@localhost:1025 eine Verbindung zum lokalen Port 1025 hergestellt.
Wenn Sie nach der Bestätigungsmeldung Host hinzugefügt aufgefordert werden, eine Verbindung herzustellen, klicken Sie auf Verbinden.
Möglicherweise werden Sie vom System aufgefordert, den Hash zu bestätigen. Klicken Sie auf Weiter, wenn Sie dazu aufgefordert werden.
Ein neuer VS Code-Editor wird geöffnet und in der VS Code-Statusleiste wird SSH: localhost: gefolgt von der Portnummer angezeigt.
Sie haben jetzt Zugriff auf die Dateien und Sprachserver auf Ihrer Remote-Workstation und können Prozesse erstellen und ausführen, die auf Ihrer Workstation ausgeführt werden.
Das folgende Beispiel zeigt ein VS Code-Editorfenster, das über SSH: localhost: 1025 mit Cloud Workstations verbunden ist.
Sie können auch zum Extensions Marketplace zurückkehren, um Cloud Code und andere lokale VS Code-Erweiterungen zu installieren, mit denen Sie Ihren Code erstellen, ausführen und testen können.
[[["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-08-11 (UTC)."],[],[],null,["# Develop code using a local VS Code editor\n\nLearn how to open an SSH tunnel from your local machine\nto a workstation, and then use\n[VS Code Remote Development](https://code.visualstudio.com/docs/remote/remote-overview)\nsupport to connect to Cloud Workstations from your local VS Code editor.\n| **Tip:** For an in-browser experience, you can use the Cloud Workstations IDE [Code OSS for Cloud Workstations](/workstations/docs/base-editor-overview), which is based on the [Code-OSS](https://github.com/microsoft/vscode) open source project.\n\nBefore you begin\n----------------\n\nBefore you begin, make sure that you follow the steps for these tasks:\n\n1. Make sure that someone on your team has created a [workstation configuration](/workstations/docs/create-configuration).\n2. [Create and start your workstation](/workstations/docs/create-workstation).\n3. While you're in the Google Cloud console, copy the following information:\n\n 1. Project name and ID: click the project name in the Google Cloud menu bar and copy the ID in the **Project name and ID** dialog that opens.\n 2. Region\n 3. Cluster name\n 4. Configuration name\n4. From your local machine,\n [install the `gcloud` CLI](/sdk/docs/install).\n\n If you're running `gcloud` CLI for the first time, you may also\n need to run `gcloud auth login` to obtain credentials and\n `gcloud config set project `\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e to set your current\n project to the project ID you copied in the previous step.\n5. When using `ssh` for the first time, install a remote SSH extension so you\n can connect to a workstation from the VS Code editor through the\n Extension Marketplace or through the command palette.\n\n ### Extension Marketplace\n\n 1. Open your local VS Code editor application and then open the\n Extension Marketplace by selecting \n\n **Extensions** in the Activity bar.\n\n 2. Click **Install** to install the **Remote - SSH** extension.\n\n 3. Enter `remote ssh` in the search field, which opens the extension page\n for **Remote - SSH.**\n\n ### Command palette\n\n 1. To open the command palette, press \u003ckbd\u003eControl+Shift+P\u003c/kbd\u003e\n (or \u003ckbd\u003eCommand+Shift+P\u003c/kbd\u003e on macOS), or click\n **View** \\\u003e **Command Palette**.\n\n 2. Enter `ext install ms-vscode-remote.remote-ssh` to install the\n extension.\n\nOpen an SSH tunnel\n------------------\n\nOpen an SSH tunnel from your local machine to a workstation using the\n[`gcloud workstations start-tcp-tunnel`](/sdk/gcloud/reference/workstations/start-tcp-tunnel)\ncommand:\n\n1. In the Google Cloud console,\n go to the **Cloud Workstations** \\\u003e **Workstations** page.\n\n\n [Go to Workstations](https://console.cloud.google.com/workstations/list)\n\n \u003cbr /\u003e\n\n2. Click the workstation name to open the **Workstation details** page.\n\n3. In the following example, replace the placeholders for the\n workstation name, region (location), workstation cluster name, and\n workstation configuration name. Copy the values from the Workstation details\n panel into the placeholders marked with an\n editEdit icon.\n\n gcloud workstations start-tcp-tunnel \\\n --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --region=\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e \\\n --cluster=\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e \\\n --config=\u003cvar translate=\"no\"\u003eCONFIG_NAME\u003c/var\u003e \\\n --local-host-port=:\u003cvar translate=\"no\"\u003eLOCAL_PORT\u003c/var\u003e \\\n \u003cvar translate=\"no\"\u003eWORKSTATION_NAME\u003c/var\u003e 22\n\n See the\n [Before you begin](/workstations/docs/develop-code-using-local-vscode-editor#before_you_begin)\n section to find the project ID.\n\n The `--local-host-port=:`\u003cvar translate=\"no\"\u003eLOCAL_PORT\u003c/var\u003e flag is optional.\n If you would like to specify a local port, replace\n \u003cvar translate=\"no\"\u003eLOCAL_PORT\u003c/var\u003e with the local port number that you want\n to use. If you don't specify a local port, the system chooses an\n arbitrary, unused local port for you, and outputs a message with the port\n number so you know which local port it uses.\n4. After filling in the placeholders, click\n content_copy\n **Copy code sample** to copy the `gcloud` CLI command.\n\n5. Paste the command into your local terminal window and press \u003ckbd\u003eEnter\u003c/kbd\u003e\n to create the tunnel.\n\n When the command succeeds, a `Listening on port` message appears followed by\n the local port number.\n\n\nFor more details about each configuration flag, see\n[SSH tunnel](/workstations/docs/ssh-support)\nor\n[`start-tcp-tunnel`](/sdk/gcloud/reference/workstations/start-tcp-tunnel).\n\nConnect to a Cloud Workstations host\n------------------------------------\n\nFollow these steps to connect to a Cloud Workstations host:\n\n1. Open or return to the VS Code application.\n2. To launch **Remote - SSH** , click\n **Open a Remote Window** in the status bar.\n\n3. Select the **Connect to Host** option when the command palette opens.\n\n4. Enter `user@localhost:`\u003cvar translate=\"no\"\u003eLOCAL_PORT\u003c/var\u003e, replacing\n \u003cvar translate=\"no\"\u003eLOCAL_PORT\u003c/var\u003e with your local port number.\n\n The following example connects to local port `1025` by specifying\n `user@localhost:1025`.\n\n | **Note:** The host keys for the workstations change between sessions because workstations run on ephemeral VMs. Ensure that host key validation is disabled for the workstation configuration for this reason.\n5. If prompted to connect after you see the **Host Added** confirmation\n message, click **Connect**.\n\n The system might also prompt you to confirm the hash. If prompted, click\n **Continue**.\n6. A new VS Code editor opens and the VS Code status bar shows\n **SSH: localhost:** followed by the port number.\n\n You now have access to the files and language servers on your remote workstation,\n and you can build and run processes that run inside your workstation.\n\n The following example shows a VS Code editor window connected to\n Cloud Workstations through **SSH: localhost: 1025**.\n\n You can also go back to the Extensions Marketplace to install\n [Cloud Code](/code/docs)\n and other local VS Code extensions to help you\n build, run, and test your code."]]