【发布时间】:2014-05-20 23:24:18
【问题描述】:
我目前正在尝试使用 ssh 在 Windows 上使用 git。我生成了一个密钥(使用 ssh-keygen -t rsa)并将公钥添加到 github。不幸的是,每次我连接时都会出现以下内容:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'C:\\Users\\DaGeRe\\.ssh\\id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: C:\\Users\\DaGeRe\\.ssh\\id_rsa
Enter passphrase for C:\Users\DaGeRe\.ssh\id_rsa:
所以,为了让它工作,我已经完成了 chmod 700(就像在无尽的帖子中推荐的那样,例如 SSH Private Key Permissions using Git GUI or ssh-keygen are too open ),并且 ls 返回以下内容:
-rw-r--r-- 1 DaGeRe mkpasswd 951 May 20 10:59 id_rsa
-rw-r--r-- 1 DaGeRe mkpasswd 239 May 20 10:59 id_rsa.pub
但不幸的是, ssh-add C:\Users\DaGeRe.ssh\id_rsa 或 ssh -T git@github.com 仍然返回错误。 chmod 命令似乎不起作用,甚至 chmod -c 700 id_rsa(就像这里所说的:https://superuser.com/questions/397288/using-cygwin-in-windows-8-chmod-600-does-not-work-as-expected)也没有改变任何东西。
尝试删除窗口的所有权限(通过设置中的菜单)也不起作用。在属性 -> 安全(我也翻译自“Eigenschaften -> Sicherheit”)中添加用户“Everyone”(德语:“Jeder”,用户可能在英文窗口中称为不同)并拒绝他的任何访问后,警告消失。
使用第一个空密码密钥,来自 ssh-add 的输出如下:
C:\Users\DaGeRe\.ssh>ssh-add id_rsa
Enter passphrase for id_rsa:
在这之后,什么都没有显示。但是 ssh-add -l 也什么都不返回:
C:\Users\DaGeRe\.ssh>ssh-add -l
The agent has no identities.
如果我添加一个密码,它总是说密码是错误的,有错误的权利(所以从一开始就出现了消息)和正确的权利(所以没有出现错误,但它仍然说正确的短语是错了)。
我在 Windows 上使用 OpenSSH 3.8.1,但我没有安装 cygwin。
因此,即使权利设置正确,它似乎也没有被添加。如果有人提示如何解决这个问题,我会很高兴。
这是 ssh -vT git@github.com 的输出
OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004
debug1: Reading configuration data /cygdrive/c/Users/DaGeRe/.ssh/config
debug1: Applying options for github.com
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to github.com [192.30.252.130] port 22.
debug1: Connection established.
debug1: identity file "/cygdrive/c/Users/DaGeRe/.ssh/id_rsa" type -1
debug1: Remote protocol version 2.0, remote software version libssh-0.6.0
debug1: no match: libssh-0.6.0
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-sha1 none
debug1: kex: client->server aes128-cbc hmac-sha1 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /cygdrive/c/Users/DaGeRe/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: "/cygdrive/c/Users/DaGeRe/.ssh/id_rsa"
debug1: No more authentication methods to try.
Permission denied (publickey).
【问题讨论】:
-
您运行的确切 chmod 命令是什么?因为在正确的 chmod 命令之后, ls 会显示 -rw----- 而不是 -rw-r--r--
-
这可能是你需要做的:cd .ssh,然后 chmod 700 *
-
我已经运行了 chmod 700 id_rsa (在正确的文件夹中),它似乎可以工作。如果我使用不存在的文件执行此操作,它会显示“chmod:获取'asd'的属性:没有这样的文件或目录”。但我不知道为什么它没有设置权利..
-
是什么让它看起来有效?如果你之后直接执行 ls -l id_rsa ,它会显示什么?
-
它显示
-rw-r--r-- 1 DaGeRe mkpasswd 951 May 20 10:59 id_rsa。我认为它会起作用,因为如果 chmod 找不到文件,它会显示错误。chmod -c 600 id_rsa(就像这里:superuser.com/questions/397288/…)也没有返回任何内容。什么也可能很重要:我只安装了 OpenSSH 和一些命令,而不是整个 cygwin。