ChatGPT解决这个技术问题 Extra ChatGPT

存储库访问被拒绝。通过部署密钥访问是只读的

从heroku成功克隆我的repo并添加另一个遥控器后

1/ git clone git@heroku.com:[APP].git
2/ git remote add bitbucket ssh://git@bitbucket.org/[ACCOUNT]/[REPO].git
3/ git push bitbucket master

运行第 (3) 行或使用 SourceTree 后我仍然收到此错误

conq: repository access denied. access via a deployment key is read-only.

首先,我不明白这条消息在实践中意味着什么。这是耻辱。

我确实创建了 ssh 密钥对并添加到 heroku :

ssh-keygen -t rsa 
heroku keys:add ./id_rsa.pub 

我还在 BitBucket 的部署密钥部分添加了我的密钥。但我一定是错过了什么。这个问题不是出于懒惰,我一直在阅读各种文档,包括 BitBuckets 指南。但它仍然没有解决这个问题。

这篇文章与Can I import my heroku git repo into bitbuket? and how?有关

其他事实:

ssh -T hg@bitbucket.org
conq: authenticated via a deploy key.

You can use git or hg to connect to Bitbucket. Shell access is disabled.


$ ssh -v git@bitbucket.org
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/joel/.ssh/config
debug1: Applying options for bitbucket.org
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug1: Connecting to bitbucket.org [207.223.240.181] port 22.
debug1: Connection established.
debug1: identity file /Users/joel/.ssh/id_rsa type 1
debug1: identity file /Users/joel/.ssh/id_rsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /Users/joel/.ssh/known_hosts:5
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/joel/.ssh/id_rsa
debug1: Remote: Forced command: conq deploykey:13907
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: read PEM private key done: type RSA
debug1: Remote: Forced command: conq deploykey:13907
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([207.223.240.181]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LC_CTYPE = UTF-8
PTY allocation request failed on channel 0

看起来一切都很好。

添加 SSH 密钥而不是部署密钥对我有用
请记住对问题和答案进行投票。干杯!!

v
vsync

我的第一个困惑是关于在 BitBucket 中设置 SSH 密钥的确切位置。

我是 BitBucket 的新手,我正在设置一个仅提供读取访问权限的部署密钥。

因此,请确保您在 BitBucket 帐户设置 中设置了您的 rsa pub key

单击您的 BitBucket 头像并选择 Bitbucket 设置(管理帐户)。在那里您将能够设置 SSH 密钥。

我只是删除了部署密钥,我现在不需要。它奏效了

https://i.stack.imgur.com/AHlFv.png


感谢你的回答。这与我所缺少的完全相同。我添加了部署密钥而不是 SSH 密钥。
是的!谢谢您的回答。 Atlassian 应该在他们的文档中更清楚地说明这一点。
是的,ssh 密钥菜单很好地隐藏在 Bitbucket 中!
很大的帮助!慈悲乔尔马兰豪!
挣扎了30分钟才找到答案,非常感谢
S
Sathish

现在 SSH 选项在安全设置下

单击您的头像 --> Bitbucket 设置 --> SSH 密钥 --> 添加密钥

粘贴您的公钥


谢谢你。我只是想描述一下我的情况。我在存储库设置中添加了我的公钥,而不是在我的 Bitbucket 帐户密钥中。所以我删除了存储库中的密钥并将其添加到我的配置文件设置中以使其正常工作。
T
Tomer

您需要将您的密钥添加到您的个人资料中,而 NOT 到特定的存储库。按照这个:https://community.atlassian.com/t5/Bitbucket-questions/How-do-I-add-an-SSH-key-as-opposed-to-a-deployment-keys/qaq-p/413373


这是我的情况谢谢!
T
Tim Hysniu

部署密钥是只读的。要启用写访问,您需要:

从您的存储库设置中删除此部署密钥。无论如何,您将无法使用此密钥写入此存储库。

转到“头像 -> 设置 -> SSH 密钥”并添加相同的密钥

现在尝试推送删除分支

您之前可以写入存储库,但这是 BitBucket 中的一个更改,您不再能够使用部署密钥进行写入。


谢谢这在拉长头发后对我有用
D
Dan Swain

“部署密钥”仅用于只读访问。以下是解决此问题的好方法。

创建一个 SSH 密钥并将其添加到 BitBucket(用户头像 -> Bitbucket 设置 -> SSH 密钥)

~/.ssh/known_hosts

ssh-add -D(删除加载到 SSH 代理的密钥)

ssh-add ~/.ssh/your_private_key_for_bitbucket

ssh git@bitbucket.org -Tv(验证您的密钥是否已习惯连接到 bitbucket)

git push '远程名称' '分支名称'


s
sent.ror

如果要在管理帐户 SSH 密钥下添加相同的密钥,则必须先删除部署密钥。


删除部署密钥会给我 Someone has already registered this as a deploy key.
请注意,您应该在 BITBUCKET SETTINGS 下添加 shh 公钥(与完整的 BB 帐户一样)NOT,我在各个 Repo Settings 下重复 NOT。如果您在 repo 设置下添加了一个密钥,这就是您收到这些错误的原因。
T
Tjunkie

TLDR:ssh-add ~/.ssh/yourkey

我刚刚解决了这个问题。

其他答案都没有帮助。

我确实有一个 ./ssh/config 包含所有正确的东西,还有一个早期的存储库工作正常(相同的 bitbucket 帐户,相同的密钥)。然后我生成了一个 deploy_key,然后创建了一个新的存储库。

之后无法克隆新的仓库。

我希望我知道 ssh 代理如何/为什么搞砸了,但添加密钥解决了它。我的意思是在我的本地 Ubuntu 中添加密钥,而不是在 bitbucket 管理员中。命令只是

    ~/.ssh$ ssh-add myregualrkey

希望这可以帮助某人。


出色的。这正是我想要的。
我不明白你做了什么。
是的,对于每个添加 -A 的人来说,您必须首先实际添加密钥。
K
Kabir Sarin

我在尝试使用部署密钥时发生了这种情况,因为这正是我想要的。

我可以通过 ssh -T git@bitbucket.org 连接,它会告诉我我有权读取我想要的存储库,但 git clone 会失败。

清除 ~/.ssh/known_hosts,通过 ssh-keygen 生成一个新密钥,将该新密钥添加到 bitbucket,然后重试为我修复它。


D
David Liu

我想再次强调以下几点:

您可能已将 SSH 密钥添加到您的存储库(例如 ExampleRepo),但这不是 SSH 密钥所在的位置。

它旨在进入您的个人资料。这是屏幕左下角的小头像。在这里,你会找到一个不同的地方来放置你的 SSH 密钥(在安全性下)> 然后你在这里添加密钥。

如果您不小心将 SSH 密钥放入存储库(而不是您的帐户),请删除存储库中的那个。

我花了很长时间才意识到,即使在阅读了这里的答案之后,它也没有点击。


I
Ivan Ogai

首先选择或创建要用于推送到 Bitbucket 的密钥。假设它的公钥在 ~/.ssh/bitbucket.pub

通过登录并转到您的公共配置文件、设置、ssh-key、添加密钥,将您的公共密钥添加到 Bitbucket。

配置 ssh 以在与 Bitbucket 通信时使用该密钥。例如在 Linux 中添加到 ~/.ssh/config:

    Host bitbucket.org
    IdentityFile ~/.ssh/bitbucket

Y
Yoones Mehdian

最近我遇到了同样的问题。我收到以下错误:

存储库访问被拒绝。通过部署密钥进行的访问是只读的。

您可以拥有两种 SSH 密钥:

对于您的整个帐户,它将适用于所有存储库每个存储库 SSH 密钥,只能用于该特定存储库。

我只是删除了我的存储库 SSH 密钥并在我的帐户中添加了一个新的 SSH 密钥,它运行良好。

我希望它可以帮助某人。干杯


L
Lippai Zoltan

我有同样的问题 Kabir Sarin 有。解决方案是通过 SSH 克隆 repo,而不是使用 https URL。所以这对我有帮助,希望对其他人有帮助:

    git clone git@bitbucket.org:{accountName}/{repoName}.git

A
Akshay Vijay Jain

能够推拉的两步过程步骤1:在mac上生成ssh密钥(公钥和私钥)步骤2:将私钥放在mac中,将公钥放在git网站下面详细步骤适用于mac用户

第 1 步:生成密钥

(确保您已安装 git)https://git-scm.com/download/mac 打开终端并输入 ssh-keygen 这将提示您输入密钥的存储位置,您可以输入 /Users/[machinename]/。 ssh/[keyname] 接下来它会要求输入密码,你可以按回车键将其留空,或者在下一个提示符下输入要再次输入的关键字 这将为您创建两个密钥,私有和公共,名称为 [keyname]和 [keyname].pub

Step2:将密钥推送到适当的位置[mac和远程帐户,即Github、bitbucket、gitlab等]

在终端中键入 ssh-add -K ~/.ssh/[keyname] 以将您的私钥添加到 mac 键入 pbcopy < ~/.ssh/[keyname].pub 将公钥复制到剪贴板 在您各自的 git 上打开帐户设置网站并去添加密钥,粘贴上面复制的公钥

完成,现在你可以推拉。


对于那些投反对票的人,我整天都在苦苦挣扎,找不到任何直接解决我问题的答案,而这里提到的步骤直接解决了它们,而且它们是通用的。无论如何
r
rahul darga

脚步:

在源服务器 ssh-keygen Cat 上创建 ssh 密钥并复制位于 ~./ssh 目录下的 id_rsa.pub 转到 Bitbucket,如果您已经为存储库设置了访问密钥,则删除现有的公钥 转到 Bitbucket头像> Bitbucket 设置> SSH 密钥(在安全性,左窗格下)> 单击“添加密钥”> 粘贴公钥。通过在源服务器上运行以下命令检查它是否有效 git remote show origin 对于从源服务器获取和推送,如果协议是“https”,那么您必须通过运行以下命令将其更改为“git+ssh” git remote set-url origin git+ssh://@bitbucket.org//repo.git 检查是否可以推送到 repo。

完毕!


正确答案已经给出了 3 或 4 次,这有什么意义?为什么不尝试回答仍然没有答案的问题。
谢谢你的善意建议。
V
Victor Perov

您所需要的一切 - 添加另一个密钥并使用它。

正如我发现的第一个密钥 - 始终是部署密钥。


s
sean

有时它不起作用,因为您在 ~/.ssh/config 中为 bitbucket 手动设置了另一个密钥。


K
Kais Tounsi

这是从给定 BitBucket 团队/用户克隆所有 repos 的完整代码

# -*- coding: utf-8 -*-
"""

    ~~~~~~~~~~~~

    Little script to clone all repos from a given BitBucket team/user.

    :author: https://thepythoncoding.blogspot.com/2019/06/python-script-to-clone-all-repositories.html
    :copyright: (c) 2019
"""

from git import Repo
from requests.auth import HTTPBasicAuth

import argparse
import json
import os
import requests
import sys

def get_repos(username, password, team):
    bitbucket_api_root = 'https://api.bitbucket.org/1.0/users/'
    raw_request = requests.get(bitbucket_api_root + team, auth=HTTPBasicAuth(username, password))
    dict_request = json.loads(raw_request.content.decode('utf-8'))
    repos = dict_request['repositories']

    return repos

def clone_all(repos):
    i = 1
    success_clone = 0
    for repo in repos:
        name = repo['name']
        clone_path = os.path.abspath(os.path.join(full_path, name))

        if os.path.exists(clone_path):
            print('Skipping repo {} of {} because path {} exists'.format(i, len(repos), clone_path))
        else:
            # Folder name should be the repo's name
            print('Cloning repo {} of {}. Repo name: {}'.format(i, len(repos), name))
            try:
                git_repo_loc = 'git@bitbucket.org:{}/{}.git'.format(team, name)
                Repo.clone_from(git_repo_loc, clone_path)
                print('Cloning complete for repo {}'.format(name))
                success_clone = success_clone + 1
            except Exception as e:
                print('Unable to clone repo {}. Reason: {} (exit code {})'.format(name, e.stderr, e.status))
        i = i + 1

    print('Successfully cloned {} out of {} repos'.format(success_clone, len(repos)))

parser = argparse.ArgumentParser(description='clooney - clone all repos from a given BitBucket team/user')

parser.add_argument('-f',
                    '--full-path',
                    dest='full_path',
                    required=False,
                    help='Full path of directory which will hold the cloned repos')

parser.add_argument('-u',
                    '--username',
                    dest="username",
                    required=True,
                    help='Bitbucket username')

parser.add_argument('-p',
                    '--password',
                    dest="password",
                    required=False,
                    help='Bitbucket password')

parser.add_argument('-t',
                    '--team',
                    dest="team",
                    required=False,
                    help='The target team/user')

parser.set_defaults(full_path='')
parser.set_defaults(password='')
parser.set_defaults(team='')

args = parser.parse_args()

username = args.username
password = args.password
full_path = args.full_path
team = args.team

if not team:
    team = username

if __name__ == '__main__':
    try:
        print('Fetching repos...')
        repos = get_repos(username, password, team)
        print('Done: {} repos fetched'.format(len(repos)))
    except Exception as e:
        print('FATAL: Could not get repos: ({}). Terminating script.'.format(e))
        sys.exit(1)

    clone_all(repos)

更多信息:https://thepythoncoding.blogspot.com/2019/06/python-script-to-clone-all-repositories.html


R
Roozbeh Zabihollahi

对于此错误:conq:存储库访问被拒绝。通过部署密钥进行的访问是只读的。

我更改了我的密钥的名称,例如

cd /home/try/.ssh/
mv try id_rsa
mv try.pub id_rsa.pub

我在 bitbucket 上使用自己的密钥


关注公众号,不定期副业成功案例分享
关注公众号

不定期副业成功案例分享

领先一步获取最新的外包任务吗?

立即订阅