[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-19。"],[],[],null,["# Use SSH to access JupyterLab\n============================\n\nThis guide describes how to access your Vertex AI Workbench instance's\nJupyterLab user interface by using SSH port forwarding.\n\nSet up SSH port forwarding and access the JupyterLab user interface\n-------------------------------------------------------------------\n\nTo set up\n[SSH port forwarding](/solutions/connecting-securely#port-forwarding-over-ssh),\ncomplete the following steps, and then access your JupyterLab session through a\nlocal browser:\n\n1. Run the following command by using the [Google Cloud CLI](/sdk/gcloud) in\n your preferred terminal or in\n [Cloud Shell](https://console.cloud.google.com?cloudshell=true):\n\n ```bash\n gcloud compute ssh \\\n --project PROJECT_ID \\\n --zone ZONE \\\n INSTANCE_NAME \\\n -- -L 8080:localhost:8080\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your [Google Cloud project ID](/resource-manager/docs/creating-managing-projects#identifying_projects)\n - \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: the [zone](/compute/docs/regions-zones) where your instance is located\n - \u003cvar translate=\"no\"\u003eINSTANCE_NAME\u003c/var\u003e: the name of your instance\n\n If using Cloud Shell to run the command, add a `-4` to\n the SSH flags to use IPv4 to connect. For example: \n\n ```bash\n -- -4 -L LOCAL_PORT:localhost:REMOTE_PORT\n ```\n2. Access your JupyterLab session through a local browser:\n\n - If you ran the command on your local machine, visit\n `https://localhost:8080` to access JupyterLab.\n\n - If you ran the command using\n [Cloud Shell](https://console.cloud.google.com?cloudshell=true),\n access JupyterLab through the\n Web\n Preview on port 8080.\n\nWhy you might need to access your instance by using SSH\n-------------------------------------------------------\n\nTo get HTTPS access to JupyterLab, your Vertex AI Workbench\ninstance must have access to a Google Cloud proxy service.\nWhen the instance starts, it attempts to register itself with\nthe proxy service. If it fails to get proxy access,\nyour instance prompts you to access JupyterLab through SSH.\n\nThe following are common reasons why you might not have HTTPS access to\nJupyterLab:\n\n- Your JupyterLab instance's proxy-mode metadata setting\n is incorrect.\n\n- Your network is configured to block internet access for the\n virtual machines (VMs) running JupyterLab notebooks.\n\n- Your instance doesn't have an external IP address.\n\n- Your [VPC Service Controls](/vpc-service-controls/docs/overview) settings\n block access to [Artifact Registry](/artifact-registry/docs/overview).\n\nThe following sections show how to resolve these issues.\n\nFor changes to take effect, you might need to restart the notebook's VM when\nattempting to resolve these issues.\n\nYour JupyterLab instance's proxy-mode metadata setting is incorrect\n-------------------------------------------------------------------\n\nBy default, when you create a Vertex AI Workbench instance,\nVertex AI Workbench adds the proxy-mode metadata setting.\nIf you change or remove the proxy-mode metadata setting, then\nthe instance can't connect to the proxy service.\n\nTo add or modify the metadata to ensure there's a proxy-mode entry set\nto the correct value (for example: `project_editors`), use the\n[`projects.locations.instances.patch`](/vertex-ai/docs/workbench/reference/rest/v2/projects.locations.instances/patch)\nmethod in the Notebooks API or the\n[`gcloud workbench instances update`](/sdk/gcloud/reference/workbench/instances/update)\ncommand in the Google Cloud SDK.\n\nThe network is blocking internet access\n---------------------------------------\n\nYour JupyterLab instance accesses the proxy service through a public URL.\nIf your Virtual Private Cloud network settings block access to the public internet\nor your firewall rules block egress traffic, you must use SSH to access\nyour Vertex AI Workbench instance.\nIf possible, you might want to work\nwith your network and firewall administrators to allow access to your\ninstance through the public internet.\n\nYour instance doesn't have an external IP address\n-------------------------------------------------\n\nYou might have created your Vertex AI Workbench instance\nwithout an external IP address. If you need to change this,\ncomplete the following steps.\n\n1. In the Google Cloud console, go to the **Instances** page.\n\n [Go to Instances](https://console.cloud.google.com/vertex-ai/workbench/instances)\n2. Click the name of the instance that you need to modify.\n\n3. Click **View VM details**.\n\n4. Click **Edit**.\n\n5. In the **Network interfaces** section, expand the network that\n you want to have an external IP address.\n\n6. Click the **External IP address** drop-down menu,\n and select the option that you want.\n To resolve this issue, you must not choose **None**.\n\n7. In the **Network interfaces** section, click **Done**.\n\n8. Click **Save**.\n\nVPC Service Controls settings are blocking access to Artifact Registry\n----------------------------------------------------------------------\n\nTo connect to the proxy service,\nyour Vertex AI Workbench instance runs an\nagent that it downloads from Artifact Registry. Without this agent\nyour instance cannot connect to the proxy service.\n\nIf your VPC Service Controls settings are blocking access to\nArtifact Registry, you must add the Artifact Registry\nservice to the service perimeter of your VPC Service Controls.\n[Learn more about how service perimeters\nwork and what services VPC Service Controls can be used\nto secure](/vpc-service-controls/docs/overview#capabilities).\n\nFurther troubleshooting\n-----------------------\n\nIf you are still having trouble connecting, try reviewing the console\nlogs for your virtual machine. These logs might help you discover why\nthe Vertex AI Workbench instance is unable\nto register with the proxy service.\n\nTo access these logs, complete the following steps:\n\n1. In the Google Cloud console, go to the **Instances** page.\n\n [Go to Instances](https://console.cloud.google.com/vertex-ai/workbench/instances)\n2. Select the instance that you want to troubleshoot.\n\n3. In **Logs** , click **Serial port 1 (console)**.\n\nWhat's next\n-----------\n\nFor tips on resolving other issues,\nsee the [troubleshooting section on\nVertex AI Workbench instances](/vertex-ai/docs/general/troubleshooting-workbench#instances)."]]