window 本地私钥文件权限过于宽松的解决

[powershell]

# 替换为你的私钥完整路径
$keyPath = "D:\fileJob\1606atibm\2105oracle\vmware-centos7\ssh.key.20250215.oracle.ghost\oracle-rsa-ghost-nopsw"

# 1. 移除所有继承的权限
icacls $keyPath /inheritance:r

# 2. 仅授予当前用户完全控制权限
icacls $keyPath /grant "$env:USERNAME`:F"

# 3. 移除其他所有用户/组的权限
icacls $keyPath /remove "BUILTIN\Users" "NT AUTHORITY\Authenticated Users"

# 4. 验证权限(可选)
icacls $keyPath



------------------- 之前的私钥文件权限宽松报错  ------------------
C:\windows\system32>ssh -i "D:\fileJob\1606atibm\2105oracle\vmware-centos7\ssh.key.20250215.oracle.ghost\oracle-rsa-ghost-nopsw" at@mint.kc.com
Bad permissions. Try removing permissions for user: BUILTIN\\Users (S-1-5-32-545) on file D:/fileJob/1606atibm/2105oracle/vmware-centos7/ssh.key.20250215.oracle.ghost/oracle-rsa-ghost-nopsw.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'D:\\fileJob\\1606atibm\\2105oracle\\vmware-centos7\\ssh.key.20250215.oracle.ghost\\oracle-rsa-ghost-nopsw' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "D:\\fileJob\\1606atibm\\2105oracle\\vmware-centos7\\ssh.key.20250215.oracle.ghost\\oracle-rsa-ghost-nopsw": bad permissions
Bad permissions. Try removing permissions for user: BUILTIN\\Users (S-1-5-32-545) on file D:/fileJob/1606atibm/2105oracle/vmware-centos7/ssh.key.20250215.oracle.ghost/oracle-rsa-ghost-nopsw.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'D:\\fileJob\\1606atibm\\2105oracle\\vmware-centos7\\ssh.key.20250215.oracle.ghost\\oracle-rsa-ghost-nopsw' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "D:\\fileJob\\1606atibm\\2105oracle\\vmware-centos7\\ssh.key.20250215.oracle.ghost\\oracle-rsa-ghost-nopsw": bad permissions
at@mint.kc.com's password:

----------------- 之后的登录成功  -----------------------

C:\windows\system32>ssh -i "D:\fileJob\1606atibm\2105oracle\vmware-centos7\ssh.key.20250215.oracle.ghost\oracle-rsa-ghost-nopsw" at@mint.kc.com

Last login: Sat Apr 11 22:55:52 2026 from 192.168.1.120
(base) at@vm-mint:~$