生成本地ssh key
ssh-keygen -t rsa -C "账户名"
一路回车下去:
\[root@VM-0-6-centos ~\]# ssh-keygen -t rsa -C "tioncico" Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:tUjAVTyqastk8IrdbWfJxGoYAKy94Tjr0BIOsFaH7cw tioncico The key's randomart image is: +---\[RSA 2048\]----+ |. ....o. | |.. o .. o | |oo o o .... | |o.= = ..o . | |++.+ A oS . | |*ooo. . o | |o+. ++ + . | |o+ *+.+ = | |o.o.++.o | +----\[SHA256\]-----+
启动ssh-agent 秘钥管理工具
eval \`ssh-agent\` 或者 ssh-agent bash
添加秘钥到 ssh-agent
ssh-add ~/.ssh/id_rsa #之前生成秘钥的路径
查看秘钥
git 配置公钥
未配置gitclone 情况
在git服务器后台,新增公钥
新增成功后,clone成功