- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两台电脑;我的工作站和我用来运行公司 VPN 的笔记本电脑。我需要通过 VPN 才能访问我的 Git 远程 (BitBucket)。
我的工作站上运行着一个 SSH 代理,其中包含连接到 Git 远程服务器所需的 SSH key 。我已将 SSH 配置为在连接到我的笔记本电脑时转发我的 SSH 代理:
Host my-laptop
ForwardAgent yes
如果我使用 SSH 连接到我的笔记本电脑,我可以成功 git pull
,并且 ssh-agent -l
确认 SSH 代理已正确转发。到目前为止一切顺利!
这就是挑战:我想直接从我的工作站使用 git。这应该可以通过将 SSH 配置为通过我的笔记本电脑进行代理来实现。我的 git Remote 看起来像这样:
➜ git remote -v
origin ssh://git@bitbucket.my-company.com:7999/my-team/my-project.git (fetch)
origin ssh://git@bitbucket.my-company.com:7999/my-team/my-project.git (push)
所以我添加了这个 SSH 配置:
Host *.my-company.com
ProxyJump my-laptop
代理跳转成功了,因为现在我到达了 Git 远程! 🎉
但是,身份验证失败:
git@bitbucket.my-company.com: Permission denied (publickey).
fatal: Could not read from remote repository.Please make sure you have the correct access rights
and the repository exists.
exit status 128
那么显然 SSH 代理转发在代理命令时不起作用..?
我尝试过的故障排除步骤:
使用 SSH 连接到笔记本电脑并运行 git pull
- 它有效
直接从笔记本电脑运行 git pull
- 它有效
添加 IdentityFile
和 IdentitiesOnly
以强制使用正确的 key ,但没有任何区别:
Host *.my-company.com
ProxyJump my-laptop
IdentityFile ~/.ssh/hubro@my-company.com.key
IdentitiesOnly yes
在连接到 Git 远程主机时添加 ForwardAgent yes
,没有任何区别:
Host *.my-company.com
ProxyJump my-laptop
ForwardAgent yes
IdentityFile ~/.ssh/hubro@my-company.com.key
IdentitiesOnly yes
那么为什么在运行 git 命令时没有使用我的本地 SSH 代理?
最佳答案
事实证明,在此设置中我什至不需要 SSH 代理转发,因为 ProxyJump 设置设置了一个隧道,让我的工作站“直接”与 git 远程通信。
我收到“Permission denied (publickey)”错误的原因原来是我的发行版 (Arch) 是最新的并且默认情况下已经禁用了对“ssh-rsa” key 的支持。 (在撰写本文时,Arch Linux 附带 openssh 8.8p1)
令人沮丧的是,我使用“rsa-sha2-512”生成我的 key 并不重要,它应该是安全的,我的 SSH 客户端仍然没有它。
但是,我使用 ed25519 生成了一个新 key ,这解决了我的问题。
$ ssh-keygen -t ed25519
关于git - 我可以让 SSH ForwardAgent 和 ProxyJump 与 Git 一起工作吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69583644/
我已成功地run()使用我的私钥对在远程服务器上执行命令。 但是,我想使用我的本地 key (或使用我所在的本地 ssh 代理)在远程服务器上执行 git clone ssh://private/re
有人可以说我,我做错了什么吗?我正在使用 Amazon EC2 实例并希望将代理转发给用户 rails,但是当我运行下一个任务时: - acl: name={{ item }} etype=user
我有两台电脑;我的工作站和我用来运行公司 VPN 的笔记本电脑。我需要通过 VPN 才能访问我的 Git 远程 (BitBucket)。 我的工作站上运行着一个 SSH 代理,其中包含连接到 Git
我是一名优秀的程序员,十分优秀!