"Incorrect padding" when trying to create managed Kubernetes cluster on Azure with AKS "Incorrect padding" when trying to create managed Kubernetes cluster on Azure with AKS kubernetes kubernetes

"Incorrect padding" when trying to create managed Kubernetes cluster on Azure with AKS


I am fairly confident that I solved why I'm getting this error, and I've updated issue 6142 on azure-cli. At this time, I believe this is a bug, and it's not fixed, but there is a workaround.

First it's important to note that --generate-ssh generates a new ssh key in ~/.ssh

I had a hunch that since ~ for me is "C:\Users\Matthew Groves" that the space in the path was causing the problem. Sure enough, I created a new account called "mgroves". ~ is now "C:\Users\mgroves" and voila, I don't get the "incorrect padding" error message anymore.

So, the workaround is either to use a new account (huge pain) or rename the folder (this is what I have done, and it's also a huge pain and I'm still finding little problems here and there all throughout my system because of it.


In addition to the now approved answer there is a solution that doesn't require you to change any directory or account name and is also easy to implement as well.

As correctly stated in the other answers the Azure CLI cannot handle the actual location where the generated SSH keys will be stored if there is a space in the path. I.e. C:\Users\Admin Account\.ssh\.

When using the az aks create command you can either use --generate-ssh-keys to let the Azure CLI handle it, OR you can specify an already existing SSH key with --ssh-key-value.

I used Git Bash to generate a new SSH key pair in the C:\Users\Admin Account\.ssh\ directory:

ssh-keygen -f ~/.ssh/aks-ssh

Now create the Azure AKS cluster while pointing to this new SSH key with:

az aks create \  --resource-group YourResourceGroup \  --name YourClusterName \  --node-count 3 \  --kubernetes-version 1.16.8 \  --ssh-key-value ~\.ssh\aks-ssh.pub

And you are good to go!


Just verified today using az cli in Powershell for version 2.0.31. You might need to first run the az group and then create az aks command. Screenshot for your reference. Azure CLI AKS Create