You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/aks/ssh.md
+16-12Lines changed: 16 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,19 +12,19 @@ ms.author: iainfou
12
12
13
13
# SSH to Azure Kubernetes Service (AKS) cluster nodes
14
14
15
-
Occasionally, you may need to access an Azure Kubernetes Service (AKS) node for maintenance, log collection, or other troubleshooting operations. For security purposes, the AKS nodes are not exposed to the internet. This article shows you how to create an SSH connection with an AKS node.
15
+
Throughout the lifecycle of your Azure Kubernetes Service (AKS) cluster, you may need to access an AKS node. This access could be for maintenance, log collection, or other troubleshooting operations. The AKS nodes are Linux VMs, so you can access them using SSH. For security purposes, the AKS nodes are not exposed to the internet. This article shows you how to create an SSH connection with an AKS node using their private IP addresses.
16
16
17
-
## Reset the SSH keys
17
+
## Add your public SSH key
18
18
19
-
If you did not specify SSH keys when you created your AKS cluster, you first need to reset the SSH keys for the Kubernetes nodes. To reset the SSH keys for your nodes, complete the following steps:
19
+
By default, SSH keys are generated for you when you create an AKS cluster. If you did not specify your own SSH keys when you created your AKS cluster, you first need to add your public SSH keys to the AKS nodes. To add your SSH key to an AKS node, complete the following steps:
20
20
21
21
1. Get the resource group name for your AKS cluster resources using [az aks show][az-aks-show]. Provide your own core resource group and AKS cluster name:
22
22
23
23
```azurecli
24
24
az aks show --resource-group myResourceGroup --name myAKSCluster --query nodeResourceGroup -o tsv
25
25
```
26
26
27
-
1. List the VMs in the AKS cluster resource group using the [az vm list][az-vm-list] command. These VMs are you AKS nodes:
27
+
1. List the VMs in the AKS cluster resource group using the [az vm list][az-vm-list] command. These VMs are your AKS nodes:
28
28
29
29
```azurecli
30
30
az vm list --resource-group MC_myResourceGroup_myAKSCluster_eastus -o table
@@ -38,7 +38,7 @@ If you did not specify SSH keys when you created your AKS cluster, you first nee
1. To update the SSH keys for your node, use the [az vm user update][az-vm-user-update] command. Provide the resource group name and then one of the AKS nodes obtained in the previous step. By default, the username for the AKS nodes is *azureuser*. Provide the location of your own SSH public key location, such as ~/.ssh/id_rsa.pub*, or paste the contents of your SSH public key:
41
+
1. To add your SSH keys to the node, use the [az vm user update][az-vm-user-update] command. Provide the resource group name and then one of the AKS nodes obtained in the previous step. By default, the username for the AKS nodes is *azureuser*. Provide the location of your own SSH public key location, such as *~/.ssh/id_rsa.pub*, or paste the contents of your SSH public key:
42
42
43
43
```azurecli
44
44
az vm user update \
@@ -50,7 +50,9 @@ If you did not specify SSH keys when you created your AKS cluster, you first nee
50
50
51
51
## Get the AKS node address
52
52
53
-
The AKS nodes are not publicly exposed to the internet. To SSH to the AKS nodes, you use their internal, private IP addresses. View the private IP address of an AKS cluster node using the [az vm list-ip-addresses][az-vm-list-ip-addresses] command. Provide your own AKS cluster resource group name obtained in a previous [az-aks-show][az-aks-show] step:
53
+
The AKS nodes are not publicly exposed to the internet. To SSH to the AKS nodes, you use their internal, private IP addresses.
54
+
55
+
View the private IP address of an AKS cluster node using the [az vm list-ip-addresses][az-vm-list-ip-addresses] command. Provide your own AKS cluster resource group name obtained in a previous [az-aks-show][az-aks-show] step:
54
56
55
57
```azurecli
56
58
az vm list-ip-addresses --resource-group MC_myAKSCluster_myAKSCluster_eastus -o table
To get an SSH connection to an AKS node, you run a helper pod on the node. This helper pod provides you with SSH access into the cluster and then additional SSH node access. To create and use this helper pod, complete the following steps:
71
+
To create an SSH connection to an AKS node, you run a helper pod in your AKS cluster. This helper pod provides you with SSH access into the cluster and then additional SSH node access. To create and use this helper pod, complete the following steps:
70
72
71
-
1. Run a `debian` container image and attach a terminal session to it. This container is used to create an SSH session with any node in the AKS cluster:
73
+
1. Run a `debian` container image and attach a terminal session to it. This container can be used to create an SSH session with any node in the AKS cluster:
72
74
73
75
```console
74
76
kubectl run -it --rm aks-ssh --image=debian
75
77
```
76
78
77
-
1. The base Debian image doesn't include SSH components. Install an SSH client in the container with `apt-get` as follows:
79
+
1. The base Debian image doesn't include SSH components. Once the terminal session is connected to the container, install an SSH client using `apt-get` as follows:
@@ -89,13 +91,15 @@ To get an SSH connection to an AKS node, you run a helper pod on the node. This
89
91
aks-ssh-554b746bcf-kbwvf 1/1 Running 0 1m
90
92
```
91
93
92
-
1. In the first step of this article, you added your public SSH key the AKS node. Now, copy your private SSH key into the pod. This private key is then used to create the SSH into the AKS nodes. Provide your own *aks-ssh* pod name obtained in the previous step. If needed, change *~/.ssh/id_rsa* to location of your private SSH key:
94
+
1. In the first step of this article, you added your public SSH key the AKS node. Now, copy your private SSH key into the pod. This private key is used to create the SSH into the AKS nodes.
95
+
96
+
Provide your own *aks-ssh* pod name obtained in the previous step. If needed, change *~/.ssh/id_rsa* to location of your private SSH key:
1. Back in the terminal session to your help pod, update the permissions on the `id_rsa` private SSH key copied in the previous step so that it is user read-only:
102
+
1. Back in the terminal session to your container, update the permissions on the copied `id_rsa` private SSH key so that it is user read-only:
99
103
100
104
```console
101
105
chmod 0600 id_rsa
@@ -139,6 +143,6 @@ If you need additional troubleshooting data, you can [view the kubelet logs][vie
0 commit comments