权限被拒绝,虽然我可以做 whoami

Permission denied although I can do whoami

我的本地计算机是 运行ning Windows,我正在尝试使用 Git Bash 和 SSH 连接到 Bitbucket 服务器。

如果我 运行 whoami 在远程存储库上:

ssh -p 7999 -i /c/Users/my-username/.ssh/id_rsa git@my-repo.com whoami

我得到了正确的回复:

my-username

但是,如果我尝试 ping 存储库:

ssh -T git@my-repo.com

我被要求输入密码 3 次,然后我的访问被拒绝。

This is a private computer system with access restricted to
those with proper authorization.  If you are not specifically
authorized to access data on this system, disconnect now.
All information and communications on this system are
subject to review, monitoring, and recording at any time
without notice or permission.  Unauthorized use or access
may be subject to prosecution or disciplinary action.


Password:
Password:
Password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,keyboard-interactive).

知道为什么我的访问被拒绝了吗?

编辑

我也试过了

ssh -p 7999 -T -i /c/Users/my-username/.ssh/id_rsa git@my-repo.com

结果是一样的

你似乎错过了第二个命令的私钥。因此 SSH 回落到 username/password.

尝试

ssh -p 7999 -T -i /c/Users/my-username/.ssh/id_rsa git@my-repo.com

我想 this document 解释了您无法登录的原因:

To prevent security issues, the embedded SSH server has been locked down to allow execution of a small set of commands for Git hosting. The only commands that are supported are git upload-pack, git receive-pack, git archive-pack and whoami (a custom whoami implemented in Bitbucket Server not the whoami command that exists on Linux). It is not possible to open an SSH shell using the embedded server to execute arbitrary commands on the server.

虽然这与名为 "BitBucket Server" 的产品有关,但我认为它也适用于 BitBucket 的云托管版本。