Life's random bits By b1thunt3r (aka Ishan Jain)…
SSH into Azure Kubernetes Worker Node

SSH into Azure Kubernetes Worker Node

Ishan jain
Sometimes you just need to get full access.

There have some rare occasions where I have needed to get to the host os of a worker node in Azure Kubernetes.

Pre Requites

  • Azure CLI

  • aks-preview Azure CLI extension

    az extension add --name aks-preview
    
  • Microsoft.ContainerService provider

    az provider register --namespace Microsoft.ContainerService
    
  • DisableSSHPreview feature flag

    az feature register --namespace "Microsoft.ContainerService" --name "DisableSSHPreview"
    

Update SSH public key on an existing AKS cluster

If you have lost the key used during installation of the Azure Kubernetes, you can update the key with the following command:

aks update --name myAKSCluster --resource-group MyResourceGroup --ssh-key-value ~/.ssh/id_rsa.pub

Connect to Node

  1. We need to get the IP address (EXTERNAL-IP) of the worker node

    kubectl  get nodes -o wide
    
  2. Now we can connect to worker node

    ssh -i <private_key> clouduser@<ip_addr>
    

    Where:

    • private_key: path to private key
    • ip_addr: IP Address of the Node

Resources