1.ssh-keygen -t rsa -C [邮箱地址],例如 ssh-keygen -t rsa -C pang@qq.com,在./ssh目录下生成id_rsa和id_rsa.pub文件,其中id_rsa.pub为公钥
pang@pang-PowerEdge-T640:~/workspace$ ssh-keygen -t rsa -C pang@qq.com
Generating public/private rsa key pair.
Enter file in which to save the key (/home/pang/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/pang/.ssh/id_rsa.
Your public key has been saved in /home/pang/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:APnDrewoRzyZvkoepSEa/pZE3TjQr5/ZlFKYfxZVFUs pang@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| o. .E+|
| ..o .. .|
| oo=.o . . |
| . ++*.. . |
|o o..+ooS . . |
|oo =*.o. + o |
|..=o.+. * o |
| oo++ .+ . |
| +=.. |
+----[SHA256]-----+
2.将id_rsa.pub的内容添加到git仓库./ssh目录下的authorized_keys的结尾
3.在客户端就可以执行git的其他操作