[Troubleshooting][For AzureAD user] Permission denied (publickey) problem

If you want to access remote system using command prompt and you are an AzureAD user, you’ll meet this trouble I thought.


When I’m working, I use Windows as development environment. And I don’t like using application if that can work on command prompt.

When I tried to access remote server using ssh command, I met one problem something like this.

Error occurred when you access remote server with unprotected private key

I need over 1 hour to solve this problem, so I record what I did.
I hope you guys don’t suffer with this problem.

If you are Azure AD user and you want to use ssh command on command prompt, follow me. I’ll give you a solution!

Grant access right to AzureAD user

I logged in Windows as AzureAD user. At that time we cannot find user using file’s properties.

How can we grant access right to AzureAD user?

Enter this command on your command prompt.

CACLS <filename> /G AzureAD¥<username>:R

I entered /T and /E tags and C as permission, but when you grant access right, you should enter command without that tags and with R permission.

If you want to know more detail things about CACLS, please read Microsoft official documents.

Check file’s properties. If you can see properties like as shown below, your tasks are done!

Changed file’s owner and permission entries.


ssh -i private-key username@ipAddress -o ServerAliveInternelval=30

I set ServerAliveInternelval=30 option because I want to keep the connection alive.

Try SSH connection with changed private key



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jangwook Kim

Jangwook Kim


Korean, live in Japan. The programmer. I love to learn something new things. I’m publishing my toy projects using GitHub. Visit https://www.jangwook.net.