windows 下 git 使用 ssh 克隆项目
in Code with 0 comment
windows 下 git 使用 ssh 克隆项目
in Code with 0 comment

生成配置 SSH 密钥

使用 Git Bash 生成密钥(需要安装 git)。

ssh-keygen -t ed25519 -C "test@example.com"

回车几次就只可以生成密钥了。

这里以自建的 gitea 为例,在 gitea 系统,点击用户头像,在出现的下拉列表中选择【设置】,紧接着在【SSH/GPG密钥】中【管理SSH密钥】,增加密钥,粘贴好刚才生成的公钥(id_ed25519.pub 文件内容)即可。

启动 SSH 代理

回到个人电脑 ,打开 Git Bash,运行以下命令启动 SSH 代理:

eval "$(ssh-agent -s)"

添加 SSH 密钥到 SSH 代理

ssh-add ~/.ssh/id_ed25519

这里根据使用情况调整第一步生成的私钥位置。

接下来就是 git clone 项目,如果中间出现了问题,可以使用 ssh -T git@xxx.com 来测试 ssh 的连通性,如果遇到错误,根据错误信息却网络查找,基本都能解决。

The article has been posted for too long and comments have been automatically closed.