[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["This page describes how to SSH into a Google Distributed Cloud cluster node.\n\nThis page is for IT administrators and Operators who manage the\nlifecycle of the underlying tech infrastructure. To learn more about common\nroles and example tasks that we reference in Google Cloud content, see\n[Common GKE user roles and tasks](/kubernetes-engine/enterprise/docs/concepts/roles-tasks).\n\nLimitations\n\nThe SSH keys for user and admin clusters cannot be changed or rotated after\ncluster creation. If your security policies require periodic SSH key rotation,\nrecreate the cluster to establish a new SSH key.\n\nBefore you begin\n\nTo complete these steps, you need the location of your user and admin cluster\n`kubeconfig` files. By default, these files are stored in the\n[directory where you created your admin and user clusters](/kubernetes-engine/distributed-cloud/vmware/docs/how-to/create-admin-cluster).\nFor more information on `kubeconfig`, see\n[Configuring cluster access for kubectl](/kubernetes-engine/docs/how-to/cluster-access-for-kubectl#kubeconfig)\nin the GKE documentation.\n\nGetting the IP addresses of your cluster nodes\n\nGet the IP addresses of your user cluster nodes: \n\n```\nkubectl --kubeconfig [USER_CLUSTER_KUBECONFIG] get nodes --output wide\n```\n\nwhere \u003cvar translate=\"no\"\u003e[USER_CLUSTER_KUBECONFIG]\u003c/var\u003e is the path of your user cluster's kubeconfig\nfile.\n\nGet the IP addresses of your admin cluster nodes: \n\n```\nkubectl --kubeconfig [ADMIN_CLUSTER_KUBECONFIG] get nodes --output wide\n```\n\nwhere \u003cvar translate=\"no\"\u003e[ADMIN_CLUSTER_KUBECONFIG]\u003c/var\u003e is the path of your admin cluster's kubeconfig\nfile.\n\nFor either command, note the `INTERNAL-IP` field. These are the node IP\naddresses. The `NAME` field includes the user cluster's name with an appended\nunique ID. For example, the node named `my-user-cluster-12345678-abcdef` is part\nof the user cluster named `my-user-cluster`.\n\nUsing SSH to connect to a user cluster node\n\nGet the SSH key for a user cluster: \n\n```\nkubectl --kubeconfig [ADMIN_CLUSTER_KUBECONFIG] get secrets -n [USER_CLUSTER_NAME] ssh-keys \\\n-o jsonpath='{.data.ssh\\.key}' | base64 -d \u003e \\\n~/.ssh/[USER_CLUSTER_NAME].key && chmod 600 ~/.ssh/[USER_CLUSTER_NAME].key\n```\n\nwhere:\n\n- \u003cvar translate=\"no\"\u003e[ADMIN_CLUSTER_KUBECONFIG]\u003c/var\u003e is the path of your admin cluster's kubeconfig\n file.\n\n- \u003cvar translate=\"no\"\u003e[USER_CLUSTER_NAME]\u003c/var\u003e is the name of your user cluster. You specified\n this name when\n [Creating a user cluster](/kubernetes-engine/distributed-cloud/vmware/docs/how-to/create-user-cluster).\n\nThe preceding command performs the following steps:\n\n- From the admin cluster, get the `ssh.key` field of a Secret named `ssh-keys`\n in the \u003cvar translate=\"no\"\u003e[USER_CLUSTER_NAME]\u003c/var\u003e namespace.\n\n- Base64 decode the key.\n\n- Store the decoded key in the file `~/.ssh/[USER_CLUSTER_NAME].key`.\n\n- Set appropriate access permissions for the key file.\n\nUse the key to SSH into a user cluster node: \n\n```\nssh -i ~/.ssh/[USER_CLUSTER_NAME].key anthos@[USER_NODE_IP]\n```\n\nwhere \u003cvar translate=\"no\"\u003e[USER_NODE_IP]\u003c/var\u003e is the internal IP address of a node in your user\ncluster, which you [gathered previously](#ips).\n\nUsing SSH to connect to an admin cluster node\n\nGet the SSH key for the admin cluster: \n\n```\nkubectl --kubeconfig [ADMIN_CLUSTER_KUBECONFIG] get secrets -n kube-system sshkeys \\\n-o jsonpath='{.data.vsphere_tmp}' | base64 -d \u003e \\\n~/.ssh/admin-cluster.key && chmod 600 ~/.ssh/admin-cluster.key\n```\n\nwhere \u003cvar translate=\"no\"\u003e[ADMIN_CLUSTER_KUBECONFIG]\u003c/var\u003e is the path of the admin cluster's\nkubeconfig file.\n\nThe preceding command performs the following steps:\n\n- From the admin cluster, get the `vsphere_tmp` field of a Secret named\n `sshkeys` in the `kube-system` namespace.\n\n- Base64 decode the `vsphere_tmp` field, which is the key.\n\n- Store the decoded key in the file `~/.ssh/admin-cluster.key`.\n\n- Set appropriate access permissions for the key file.\n\nUse the key to SSH into an admin cluster node: \n\n```\nssh -i ~/.ssh/admin-cluster.key anthos@[ADMIN_NODE_IP]\n```\n\nwhere \u003cvar translate=\"no\"\u003e[ADMIN_NODE_IP]\u003c/var\u003e is the internal IP address of a node in the admin\ncluster, which you [gathered previously](#ips)."]]