This page describes how to SSH into an Google Distributed Cloud cluster node.

## Before you begin

To complete these steps, you need the location of your user and admin cluster
`kubeconfig` files. By default, these files are stored in the
[directory where you created your admin and user clusters](https://docs.cloud.google.com/anthos/clusters/docs/on-prem/1.8/how-to/admin-cluster-quickstart).
For more information on `kubeconfig`, see
[Configuring cluster access for kubectl](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl#kubeconfig)
in the GKE documentation.

## Getting the IP addresses of your cluster nodes

Get the IP addresses of your user cluster nodes:

```
kubectl --kubeconfig [USER_CLUSTER_KUBECONFIG] get nodes --output wide
```

where <var translate="no">\[USER_CLUSTER_KUBECONFIG\]</var> is the path of your user cluster's kubeconfig
file.

Get the IP addresses of your admin cluster nodes:

```
kubectl --kubeconfig [ADMIN_CLUSTER_KUBECONFIG] get nodes --output wide
```

where <var translate="no">\[ADMIN_CLUSTER_KUBECONFIG\]</var> is the path of your admin cluster's kubeconfig
file.

For either command, note the `INTERNAL-IP` field. These are the node IP
addresses. The `NAME` field includes the user cluster's name with an appended
unique ID. For example, the node named `my-user-cluster-12345678-abcdef` is part
of the user cluster named `my-user-cluster`.

## Using SSH to connect to a user cluster node

Get the SSH key for a user cluster:

```
kubectl --kubeconfig [ADMIN_CLUSTER_KUBECONFIG] get secrets -n [USER_CLUSTER_NAME] ssh-keys \
-o jsonpath='{.data.ssh\.key}' | base64 -d > \
~/.ssh/[USER_CLUSTER_NAME].key && chmod 600 ~/.ssh/[USER_CLUSTER_NAME].key
```

where:

- <var translate="no">\[ADMIN_CLUSTER_KUBECONFIG\]</var> is the path of your admin cluster's kubeconfig
  file.

- <var translate="no">\[USER_CLUSTER_NAME\]</var> is the name of your user cluster. You specified
  this name when
  [Creating a user cluster](https://docs.cloud.google.com/anthos/clusters/docs/on-prem/1.8/how-to/user-cluster-quickstart).

The preceding command performs the following steps:

- From the admin cluster, get the `ssh.key` field of a Secret named `ssh-keys`
  in the <var translate="no">\[USER_CLUSTER_NAME\]</var> namespace.

- Base64 decode the key.

- Store the decoded key in the file `~/.ssh/[USER_CLUSTER_NAME].key`.

- Set appropriate access permissions for the key file.

Use the key to SSH into a user cluster node:

```
ssh -i ~/.ssh/[USER_CLUSTER_NAME].key anthos@[USER_NODE_IP]
```

where <var translate="no">\[USER_NODE_IP\]</var> is the internal IP address of a node in your user
cluster, which you [gathered previously](https://docs.cloud.google.com/anthos/clusters/docs/on-prem/1.8/how-to/ssh-cluster-node#ips).

## Using SSH to connect to an admin cluster node

Get the SSH key for the admin cluster:

```
kubectl --kubeconfig [ADMIN_CLUSTER_KUBECONFIG] get secrets -n kube-system sshkeys \
-o jsonpath='{.data.vsphere_tmp}' | base64 -d > \
~/.ssh/admin-cluster.key && chmod 600 ~/.ssh/admin-cluster.key
```

where <var translate="no">\[ADMIN_CLUSTER_KUBECONFIG\]</var> is the path of the admin cluster's
kubeconfig file.

The preceding command performs the following steps:

- From the admin cluster, get the `vsphere_tmp` field of a Secret named
  `sshkeys` in the `kube-system` namespace.

- Base64 decode the `vsphere_tmp` field, which is the key.

- Store the decoded key in the file `~/.ssh/admin-cluster.key`.

- Set appropriate access permissions for the key file.

Use the key to SSH into an admin cluster node:

```
ssh -i ~/.ssh/admin-cluster.key anthos@[ADMIN_NODE_IP]
```

where <var translate="no">\[ADMIN_NODE_IP\]</var> is the internal IP address of a node in the admin
cluster, which you [gathered previously](https://docs.cloud.google.com/anthos/clusters/docs/on-prem/1.8/how-to/ssh-cluster-node#ips).