Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Fix WARNING UNPROTECTED PRIVATE KEY FILE With OpenSSH

July 9, 2024
in A, Blog, PuTTY
0
ADVERTISEMENT

Table of Contents

WARNING UNPROTECTED PRIVATE KEY FILE

In some cases, you get the following error when trying to SSH to a remote Linux system using a private key file with key-based authentication.

1AJmP3D8XOnmwUL6JyzTZD4wzNKmouN38hSSHh2KFcUBmPwUEGkmx4p295KC

You got this because the permission to the private key is too open. So, we need to remove all users from access to the file then grant the full permission to the current log on user only.

1. Right click on the private key then select Properties.

cAIWk2TjRTXP6OE3jsYHSwpC2VhU65X9QQRkKv0v6kiX73DkGv28jpMCpLER

2. In the Properties window, select the Security tab → Advanced button.

VeDxGPCskJiaynWvTpd3DnCF2cTWDuAUOdTwaTpCbVzmebPi5jSGijvFc8Hr

3. Next, click on the Disable inheritance button.

2vfakSlGpib5dAJFNMvc7TKJeZH2JtPxvv7GQuF6riu7bUXst6sUvJbNVN67

4. Remove all inherited permissions from the file.

eWeMuEEKyrIi9LrsjSI6IS33UPtnRXh1PPIwjAvFF4Q5I8wkiyVPJriKsRyM

5. Click Add to add permission to the file.

DfhsUQwo4NWAtLBc0K6vQFfcTIdCWBWRKQrmpZ5DFsakg6lv9VE1szghkl80

6. Click on Select a principal.

lFoLykry40JZp5ZVgs6rpt6vDWBzu8s8AeH38TdeIWIQrfNg5djsPItoLaYG

7. Type the current logon username then click on the Check Name button. Or you can find it from the Advanced…window.

Smo9i85fCwjfFHczSwU9FKvoGJTYXCBNqlt4i3lTiAktIilTLbYbMpPZ8cQb

8. Select the Full control checkbox then click OK.

8e5PqbFHw0dpnSjLZivpE0SE9HydgjIumoXzM90Ow412g7juHXKW0Pw8uQ5N

9. Click OK to save the changes.

IvczNLSR7rvdn1wgIxL1Qb8cyWPnLkp31eNWdnc3b0mo2NG7G4eKLVyQ4AIM

10. Click Ok to close the Properties window.

n2EcXzTtJtvIl1rOvVqNIGnR0xEqOJeRcs1tSNl9GnRBHCE05UbD7HuQdSFb

Finally, trying to SSH to the remote server to verify it works.

bNQXzrwNdrliMqC7FUvXEVXBE8e0HjqtKJEOVZEVqxYbSxaDd3pPdMCLfA6l

Change the permission using PowerShell

Alternatively, the permissions to the private key file can be changed using the following PowerShell code snippet. The script does:

  • Set key file to a variable.
  • Remove the inherited permissions.
  • Set the full control to the current logon user.

Note: Don’t forget to change the path of your private key into the PowerShell script.

#Set Key File Variable:
  $path = "D:\PuTTY\privkey"
  New-Variable -Name Key -Value $path

#Remove Inheritance:
  Icacls $Key /c /t /Inheritance:d

#Set Ownership to Owner:
  #Key's within $env:UserProfile:
  Icacls $Key /c /t /Grant ${env:UserName}:F

  #Key's outside of $env:UserProfile:
    TakeOwn /F $Key
    Icacls $Key /c /t /Grant:r ${env:UserName}:F

#Remove All Users, except for Owner:
  Icacls $Key /c /t /Remove:g Administrator "Authenticated Users" BUILTIN\Administrators BUILTIN Everyone System Users

#Verify:
  Icacls $Key

#Remove Variable:
  Remove-Variable -Name Key

After running the script, try to SSH to the remote server to verify it works.

2KWWhlbaqkOzQjzFTBxHcuEG64nQlyJDy95n3UMhX3r8ROhimJ5w2JuBeVHl
ADVERTISEMENT

Not a reader? Watch this related video tutorial:

Rate this post
Previous Post

How to Fix Bad Permissions Try Removing Permissions for User in OpenSSH

Next Post

How to Convert OpenSSH Private Key to RSA Private Key

Related Posts

Images Hidden Due To Mature Content Settings In CivitAI

August 31, 2024

Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

August 20, 2024

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024

How to Remove The Test Mode Watermark Without Disabling Test Mode

July 28, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory