使用 SSH 克隆 git 存储库

oct*_*ian 6 git ssh

我正在尝试使用 SSH 克隆 git 存储库。因此,我在本地计算机上创建了一个 ssh 密钥对,并在 git 存储库(即 Bitbucket 服务器)上添加了公钥。

然后,正如我在这里看到的,我尝试像这样克隆:

git clone ssh://my_username@my-repository.com:7999/my_project.git

git clone ssh://git@my-repository.com:7999/my_project.git
Run Code Online (Sandbox Code Playgroud)

然而这些选项不起作用:

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

我唯一取得的进步是尝试这样做:

git clone my_username@my-repository.com:7999/my_project.git
Run Code Online (Sandbox Code Playgroud)

这要求我输入密码 3 次,然后失败。我怀疑这并没有使用 SSH,因为我认为 SSH 不应该要求输入密码。

Password:
Password:
Password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,keyboard-interactive).
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)

那么如何使用 SSH 克隆 git 存储库呢?

编辑

我在 Windows 上使用 Git Bash。

ssh-add -l
Run Code Online (Sandbox Code Playgroud)

退货

The agent has no identities.
Run Code Online (Sandbox Code Playgroud)

小智 2

您确定该主机上的 ssh 在端口 7990 上工作吗?如果这个存储库位于 bitbucket 上,那么我几乎可以肯定您可以使用 ssh 的默认端口

git clone my_username@my-repository.com/my_project.git
Run Code Online (Sandbox Code Playgroud)

就像在git 中使用 bitbucket一样