【问题标题】:Git authenticate using unknown method to my bitbucketGit 使用未知方法对我的 bitbucket 进行身份验证
【发布时间】:2019-04-13 02:18:27
【问题描述】:

所有与我相似的主题都试图解释如何配置 git 以便能够使用 bitbucket/github。 我的主题是关于不同的故事。 我可以推送/克隆/提交 - 在 bitbucket 上对我的存储库做任何我想做的事情,但是:

1) 我的存储库在设置中没有任何“访问密钥”

2) 我的 git 配置:

user.name=No Matter
user.email=anybody@fromanywhere.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=ssh://git@bitbucket.XXXX:7999/~someuser/test.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.preprod.remote=origin
branch.preprod.merge=refs/heads/preprod

当我试图找出使用了哪个 SSH 密钥时,我在 stackoverflow 上阅读了很多我应该使用“ssh -vT git@bitbucket.XXX”的主题,但最后它要求我输入密码。

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /someuser/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /someuser/.ssh/id_dsa
debug1: Trying private key: /someuser/.ssh/id_ecdsa
debug1: Trying private key: /someuser/.ssh/id_ed25519
debug1: Next authentication method: password
git@bitbucket.XXXX's password:

当我使用 git pull;git push 等命令时,如何找出 git 使用的是哪个方法/ssh 密钥?

【问题讨论】:

    标签: git ssh bitbucket


    【解决方案1】:

    您需要在命令中提供端口 - 否则 ssh 将假定您正在尝试端口 22。(在 bitbucket.XXXX:22 有一些东西在监听,但它不是您的 Bitbucket 服务器实例 - 它可能是 sshd在主机操作系统上。)

    改用ssh -Tp7999 git@bitbucket.XXXX 之类的方法。 -p 标志让您可以为 SSH 指定一个非标准端口 - 在这种情况下,根据您的 git 配置,它是端口 7999。您也可以尝试使用 ssh -Tp433 git@altssh.bitbucket.org 作为 Bitbucket Cloud 的示例。

    【讨论】:

    • @Jim_Redmond 指定端口向我展示了用于身份验证的密钥!但是下一个问题是如何检查哪个密钥用于指定存储库而不是整个域。我的仓库有空的“访问密钥”选项卡,我应该在其中放置 ssh 密钥。
    • 是否有与特定用户帐户关联的密钥?
    【解决方案2】:

    试试这个:

     ssh -v git@bitbucket.com
    

    这会给你这样的东西。

    OpenSSH_7.9p1, OpenSSL 1.1.1a  20 Nov 2018
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: Connecting to bitbucket.com [18.205.93.4] port 22.
    debug1: Connection established.
    debug1: identity file /c/Users/sdr/.ssh/id_rsa type -1
    

    在那一行你可以看到它在哪里。通常他们在这里~/.ssh/config

    【讨论】:

    • 我已经提到了 ssh -v 命令的输出。它要求我输入密码 - 所以它不使用 ssh 密钥 - 当我对我的仓库使用 git 命令时,一切正常 - 但为什么?
    • 你试过写密码吗?之后会发生什么?如果你需要一个快速的解决方案,你也可以下载 gitKraken,它具有自动 ssh gen 和与每个 git 服务的连接
    • 我不知道 bitbucket 站点上 git 用户的密码(我什至无法访问它的后端)。我只知道我的 someuser 用户的 linux 密码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-23
    • 1970-01-01
    相关资源
    最近更新 更多