目标是将我的代码加密存储在 BitBucket 远程存储库上。有些东西应该处理加密和解密,所以我选择了 gcrypt 或完整的 git-remote-gcrypt。
我有一个配置了 SSH 密钥的 Bitbucket 帐户。
这是我尝试过的。
我从手册中复制了这些命令。
git remote remove cryptremote
git remote add cryptremote gcrypt::rsync://[email protected]/user/cryptremote.git
git config remote.cryptremote.gcrypt-participants "user"
git push cryptremote master
控制台:
gcrypt:找不到存储库:rsync://[电子邮件受保护]/user/cryptremote.git
gcrypt:设置新存储库
协议版本不匹配——你的 shell 干净吗?
(请参阅 rsync 手册页以获取解释)
rsync 错误:compat.c(600) 处的协议不兼容(代码 2)[sender=v3.2.3]
错误:无法将一些引用推送到 'gcrypt::rsync://[email protected]/user/cryptremote.git'
感谢评论,我让它可以通过 HTTPS 运行。
我为自己和你写了一个小教程。
git remote add cryptremote gcrypt::rsync://[email protected]/USER/cryptremote.git
# gcrypt docs use :user but git usually uses /user format
# git remote add cryptremote gcrypt::rsync://[email protected]:USER/cryptremote.git
git config remote.cryptremote.gcrypt-participants "GPG_KEY_ID_OR_KEY_NAME"
git config remote.cryptremote.gcrypt-signingkey "GPG_KEY_ID_OR_KEY_NAME"
git push cryptremote master
gcrypt:找不到存储库:rsync://[电子邮件受保护]/user/cryptremote.git gcrypt:设置新存储库 协议版本不匹配——你的shell干净吗? (有关说明,请参阅 rsync 手册页) rsync 错误:compat.c(600) 处协议不兼容(代码 2)[sender=v3.2.3] 错误:无法将一些引用推送到 'gcrypt::rsync://[email protected]/user/cryptremote.git'
来自手册页的模板,修改为 HTTPS,示例存储库名称“cryptremote”:
git init
git remote add origin gcrypt::https://USER:[email protected]/USER/cryptremote.git
git config remote.origin.gcrypt-participants "GPG_KEY_ID_OR_KEY_NAME"
git config remote.origin.gcrypt-signingkey "GPG_KEY_ID_OR_KEY_NAME"
# removes GPG password prompts but makes the name of the key owner public
git config remote.origin.gcrypt-publish-participants true
# in case of an existing encrypted repo
git clone gcrypt::https://USER:[email protected]/USER/cryptremote.git
# in case of starting a new encrypted remote repo
git push --set-upstream origin master
man git-remote-gcrypt
gcrypt.publish-参与者
默认情况下,参与者的 gpg 密钥 ID 被隐藏 使用 gpg -R 加密。将此选项设置为 true 会禁用 该安全措施。
对有效的事情表示感谢。
但是,我不喜欢必须使用 HTTPS 和应用程序密码,因为 Bitbucket 现在强制其用户使用 HTTPS。
虽然我不确定为什么 rsync 不起作用,但问题似乎出在 Bitbucket 上,因为我在计算机和 Android 之间完美地使用了 rsync。
[email protected]
:我确认这永远不会起作用,因为 Git 远程存储库托管服务的 SSH URL 将始终使用“git
”用户(并依赖 SSH 密钥来验证和识别实际的用户帐户)。
spwhitton/git-remote-gcrypt
提交6233fde确实提到:
删除已弃用的
(改用rsync)gcrypt::ssh://
因此
rsync
URI 似乎更受支持,如 commit 3b69f81
您的情况:
gcrypt::rsync://[email protected]/user/cryptremote.git
^^^^^ ^^^
对于任何“
protocol version mismatch -- is your shell clean?
”错误消息,请尝试 输入您的 .bashrc
:
# for non-interactive sessions stop execution here -- https://serverfault.com/a/805532/67528
[[ $- != *i* ]] && return
但还要检查可能的
rsync
版本不匹配(例如,使用Bitbucket管道只是为了显示rsync
版本)。
如此处所示,如果 SSH 不起作用,
gcrypt::https://[email protected]/user/test.git
HTTPS URL 可能会更好。
所以,看起来说明各不相同,有些指示甚至不起作用;我开始尝试“:”与“/”和“https”与“rsync”与“git”的各种组合......最后找到了一个似乎有效的组合:
git remote add origin gcrypt::git@<URL>:<group>/test.git
git config remote.origin.gcrypt-participants "<my-key-id>"
git config remote.origin.gcrypt-signingkey "<my-key-id>"
git push -u origin alpha
gcrypt: Repository not found: git@<URL>:<group>/test.git
gcrypt: Setting up new repository
gcrypt: Remote ID is :id:<some hash>
gcrypt: Due to a longstanding bug, this push implicitly has --force.
gcrypt: Consider explicitly passing --force, and setting
gcrypt: gcrypt's require-explicit-force-push git config key.
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Compressing objects: 100% (2/2), done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
gcrypt: Encrypting to: -r <my-key-id>
gcrypt: Requesting manifest signature
remote:
remote: To create a merge request for master, visit:
remote: http://<URL>/<group>/test/-/merge_requests/new?merge_request%5Bsource_branch%5D=master
remote:
To <URL>:<group>/test.git
* [new branch] alpha -> alpha
Branch 'alpha' set up to track remote branch 'alpha' from 'origin'.
当我转到 gitlab 存储库时,我可以看到两个具有十六进制名称的新文件。
但是随后,我尝试将存储库克隆回来并收到以下错误:
cd somewhere-else
git clone gcrypt::git@<URL>:<group>/test.git
Cloning into 'test'...
gpg: error reading key: No public key
有什么问题吗? 刚才是我加密的,现在我无法克隆。
有什么指点吗?