【问题标题】:configuring git/ssh to access bitbucket results in keyfile rejected - format error?配置 git/ssh 以访问 bitbucket 导致密钥文件被拒绝 - 格式错误?
【发布时间】:2019-10-25 21:08:40
【问题描述】:

我已经尝试了 3 天来设置 git/ssh 以在 Windows 10 上与 bitbucket.org 一起使用。 取得了一点进展。现在日志是...

   Ian@Helike MINGW64 /m/websites/coachmaster (master)
$ ssh -v git@bitbucket.org
OpenSSH_8.0p1, OpenSSL 1.1.1c  28 May 2019
debug1: Reading configuration data /c/Users/Ian Hobson/.ssh/config
debug1: /c/Users/Ian Hobson/.ssh/config line 1: Applying options for bitbucket.org
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to bitbucket.org [18.205.93.1] port 22.
debug1: Connection established.
debug1: identity file D:\\Ian\\keyfiles\\ianhobson-bitbucket type -1
debug1: identity file D:\\Ian\\keyfiles\\ianhobson-bitbucket-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.0
debug1: Remote protocol version 2.0, remote software version conker_e350bda95a app-131
debug1: no match: conker_e350bda95a app-131
debug1: Authenticating to bitbucket.org:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /c/Users/Ian Hobson/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: D:\\Ian\\keyfiles\\ianhobson-bitbucket  explicit
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: D:\\Ian\\keyfiles\\ianhobson-bitbucket
sign_and_send_pubkey: no mutual signature supported
debug1: No more authentication methods to try.
git@bitbucket.org: Permission denied (publickey).

Ian@Helike MINGW64 /m/websites/coachmaster (master)

我可以看到它使用了正确的密钥文件。该密钥文件和 ~/.ssh/config 已从它工作的旧机器复制。

伊恩

【问题讨论】:

  • OpenSSH 不支持 .ppk 密钥。您必须使用 PuTTYgen 将 .ppk 转换为 OpenSSH 格式。顺便说一句,这不是一个真正的编程问题。
  • 尝试从它工作的旧机器复制 ~/.ssh/config 和 D:/whateer/keyfiles。在新机器上遇到同样的故障。
  • 您根本不会遇到同样的失败。现在问题大不相同了。

标签: windows git ssh bitbucket putty


【解决方案1】:

尝试使用以下方法重新生成您的密钥:

ssh-keygen -t rsa -C "my@email.com" -m PEM -P "" -f D:\Ian\keyfiles\ianhobson-bitbucket

然后将公钥添加到您的 BitBucket 配置文件中。

确保您的 ~/.ssh/config 文件引用该私钥

Host bitb
Hostname bitbucket.org
User git
IdentityFile D:\Ian\keyfiles\ianhobson-bitbucket

那么你的网址应该是:

ssh -v bitb

不是 git@bitbicket.org,这将完全绕过 SSH 配置文件)

我认为我的错误是安装 git/tortoise git 尝试使用 Putty 和 plink - 也许我尝试了混合。

我确认(正如我所做的in the discussion):不需要腻子。 OpenSSH 就够了。

【讨论】:

  • 我试过了,没想到它会工作 - 旧密钥可以在另一台机器上工作。但是,我确实登录了这么一小步。感谢那。但是“git pull”仍然失败,并显示“致命错误:没有可用的支持的身份验证方法(服务器发送:publickey)”。还没有。
  • @Ian git pull 使用的git remote -v remote URL 是什么?您的~/.ssh/config 文件的具体内容是什么?
  • 配置文件为:\n主机 bitbucket.org\n 主机名 bitbucket.org\n IdentityFile D:\Ian\keyfiles\ianhobson-bitbucket2
  • 远程 URL 为:url = git@bitbucket.org:IanHobson/.git
  • @Ian 好的,您可以添加用户,并且只能使用 bitbucket.org。我会为主机使用不同的名称,只是为了使用配置设置。
【解决方案2】:

问题解决了。 我认为我的错误是安装 git/tortoise git 试图使用 Putty 和 plink - 也许我尝试了混合。

我应该使用另一个选项 - Open-SSH? - 对于这两个程序。

我通过重置窗口并重新安装所有程序进行了漫长的恢复,所以我不能 100% 确定以这种方式删除和重新安装 git 和乌龟 git 会解决问题。

特别感谢 VonC 为他提供的所有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-25
    • 1970-01-01
    相关资源
    最近更新 更多