如何使用GitBash通过ssh克隆数据(windows10环境)

How to use the GitBash to clone data with ssh (windows 10 environment)

我该如何解决这个问题?
当我想连接我的个人 GitLab 帐户时,我收到如下图所示的错误消息

### shell script     
git clone git@gitlab.com:<username>/test1.git

GitLab server-side

Clone ssh address

PS:我已经检查并从 Whosebug 找到了一些参考,但不幸的是它对我来说不合适
1.git clone through ssh
2.SSH and Git Clone
3.git clone with ssh issue

我找到了一个很好的参考,但是很抱歉Mandarin website,但是,我可以用我的方式来分享如何处理这个问题。

第 1 步:

ls -al ~/.ssh

第 2 步:

ssh-keygen 

(使用回车键作为默认值) 第 3 步:设置配置文件

vim /c/Users/Willie/.ssh/config

Host gitlab.com
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_rsa

第 4 步:

git clone git@gitlab.com:<username>/test2.git

第 5 步:
当您完成第 4 步时
1.the test2.git 文件将下载完成
2.you 将在 ~/.ssh
中获取新文件(known_hosts)

PS:我自己创建了id_rsa和id_rsa.ub,我把它交付给Gitlab服务器。使用任何客户端的两个密钥(windows 和 Linux)。

首先检查您是否有 ~/.ssh/id_rsa 私钥/~/.ssh/id_rsa.pub public 密钥。

如果是这样,请检查您的私钥:如果每行有 70 个字符,请尝试 regenerate with the old PEM format:

ssh-keygen -m PEM -t rsa -P "" -f ~/.ssh/id_rsa

(这将覆盖您当前的密钥,但如果说当前密钥无论如何都不起作用,那应该没问题)。
更新 GitLab 端的 public 键,然后再试一次,使用简单的:

ssh -T git@gitlab.com

使用配置文件意味着使用用户并使用更短的名称:

Host gitlab
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_rsa 

表示:ssh -T gitlabgit clone gitlab:<username>/test2.git 都可以。