AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1418706
Accepted
user11273346
user11273346
Asked: 2019-03-29 08:24:31 +0800 CST2019-03-29 08:24:31 +0800 CST 2019-03-29 08:24:31 +0800 CST

为什么 chown 600 id_rsa 修复权限问题?

  • 772

我最近将我的密钥导入到一台新机器 (Mac) 并忘记将权限修改为 600。这样做时,我不小心写了chown而不是chmod. 奇怪的是,这解决了权限问题,如下所示:

% git pull origin develop
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/m/.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 "/Users/m/.ssh/id_rsa": bad permissions
git@<redacted>: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
%
% sudo chown 600 ~/.ssh/id_rsa
Password:
%
% ls -l ~/.ssh/id_rsa
-rw-r--r--@ 1 600  staff  1679 Mar 25 15:14 /Users/m/.ssh/id_rsa
%
% git pull origin develop
From <redacted>
 * branch            develop    -> FETCH_HEAD
Already up to date.
%
% ssh <redacted>
The authenticity of host '<redacted> (<redacted>)' can't be established.
ECDSA key fingerprint is <redacted>.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '<redacted>' (ECDSA) to the list of known hosts.
Warning: your password will expire in 5 days
Last login: Fri Jul 27 19:51:32 2018 from <redacted>
-bash-4.2$

为什么会这样?

ssh permissions
  • 2 2 个回答
  • 513 Views

2 个回答

  • Voted
  1. Best Answer
    Kenster
    2019-03-29T13:09:10+08:002019-03-29T13:09:10+08:00

    根据OpenSSH源代码,ssh如果文件的所有者是运行的用户,则只检查私钥文件的权限ssh。如果该文件属于另一个用户,则 ssh 将允许任何可以读取该文件的人使用它。

    if ((st.st_uid == getuid()) && (st.st_mode & 077) != 0) {
         ^^^^^^^^^^^^^^^^^^^--owner ^^^^^^^^^^^^^^^^--permissions
        error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        error("@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @");
        error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        ...
    

    这似乎没有在手册页中详细说明。

    源代码包含此注释,表明该行为是故意的:

    /*
     * if a key owned by the user is accessed, then we check the
     * permissions of the file. if the key owned by a different user,
     * then we don't care.
     */
    

    实际上,检查属于另一个用户的密钥文件的权限不会提高安全性。如果您可以读取该文件,则可以通过制作该文件的副本并限制对该副本的权限来绕过权限检查。

    • 2
  2. Jerry
    2019-03-29T08:35:53+08:002019-03-29T08:35:53+08:00

    chmod 命令代表“更改模式”,允许更改文件和文件夹的权限,在 UNIX 中也称为“模式”。chown 命令代表“更改所有者”,并允许更改给定文件或文件夹的所有者,可以是用户和组。

    • -2

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    Windows 10 服务称为 AarSvc_70f961。它是什么,我该如何禁用它?

    • 2 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Marko Smith

    ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1056)

    • 4 个回答
  • Marko Smith

    我如何知道 Windows 安装在哪个驱动器上?

    • 6 个回答
  • Martin Hope
    Albin 支持结束后如何激活 WindowsXP? 2019-11-18 03:50:17 +0800 CST
  • Martin Hope
    fixer1234 “HTTPS Everywhere”仍然相关吗? 2019-10-27 18:06:25 +0800 CST
  • Martin Hope
    Kagaratsch Windows 10 删除大量小文件的速度非常慢。有什么办法可以加快速度吗? 2019-09-23 06:05:43 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    Inter Sys Ctrl+C 和 Ctrl+V 是如何工作的? 2019-05-15 02:51:21 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve