git - 即使权限正确,也未受保护的私钥文件
问题描述
UNPROTECTED PRIVATE KEY FILE 即使权限是正确的。我尝试了 600 和 400
以下来自控制台。
令人惊讶的是,它适用于 cygwin。键的相同路径。我看到的唯一区别是 ssh 代理?
Microsoft Windows [Version 10.0.17134.112]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\source\git\project>git pull
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'C:\\Users\\<user>/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "C:\\Users\\<user>/.ssh/id_rsa": bad permissions
git@bitbucket.organisation.no: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
C:\source\git\project>ls -alh C:\\Users\\<user>/.ssh/id_rsa
-r--r--r-- 1 <user> Domain Users 3.4K Jan 13 12:48 'C:\\Users\\user/.ssh/id_rsa'
C:\source\git\project>ssh -vvvT git@bitbucket.organisation.no
OpenSSH_for_Windows_7.6p1, LibreSSL 2.6.4
debug3: Failed to open file:C:\\Users\\user/.ssh/config error:2
debug3: Failed to open file:C:\\ProgramData\\ssh/ssh_config error:2
debug2: resolving "bitbucket.organisation.no" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to bitbucket.organisation.no[xxx.xx.xx.xx] port 22.
从赛格温
$ ssh -vvvT git@bitbucket.organisation.no
OpenSSH_8.0p1, OpenSSL 1.1.1d 10 Sep 2019
debug2: resolving "bitbucket.organisation.no" port 22
debug2: ssh_connect_direct
debug1: Connecting to bitbucket.organisation.no [xxx.xx.xxx.xx] port 22.
更新:我检查权限的方式有些奇怪?
C:\Users\user\.ssh>ls -alh id_rsa
-r--------+ 1 user Domain Users 3.4K Jan 13 12:48 id_rsa
C:\Users\user\.ssh>ls -alh C:\\Users\\user\\.ssh\\id_rsa
-r--r--r-- 1 user Domain Users 3.4K Jan 13 12:48 'C:\\Users\\user\\.ssh\\id_rsa'
解决方案
您应该确保您的私钥文件不能被您以外的其他用户读取。现在,它对每个人都是可读的。
要修复私钥文件的权限,您可以运行以下命令:
chmod o-rwx C:\\Users\\user/.ssh/id_rsa
推荐阅读
- javascript - 使用 Sinon 断掉 Pino 的问题
- groovy - 如何使用 groovy 在 json 文件中断言值?
- php - now 和 mysql datetime 之间的时间差
- ruby - BeforeAll 和 AfterAll 挂钩在单独的 gem 中
- travis-ci - 如何在 Travis CI 构建中授予更新/初始化私有子模块的权限?
- image - 通过 Shopware 6 API 添加图像
- jupyter-lab - 如何解决 Jupyter Lab 500 内部服务器错误?
- javascript - 如何使用下面的代码增加视频的大小
- angular - 无法读取 tsconfig.base.json!- Apollo Angular 项目设置
- c# - C# Selenium 错误 - 操作已超时