一、检查当前mac是否已存在ssh key
输入以下命令:
ls -al ~/.ssh
二、命令生成 ssh key
ssh-keygen -t rsa -C "you_email@.com(你的邮箱,用于gitlab的邮箱)"
后面的提示直接敲回车,一路完成,使用默认值即可,因为这个Key仅仅用于简单的服务,所以也无需设置密码。
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/你的电脑用户名/.ssh/id_rsa.
Your public key has been saved in /Users/你的电脑用户名/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:******************************** 邮箱
如果服务器端需要公钥, 直接把.ssh目录下的
id_rsa.pub
配置即可,id_rsa
为私钥要保密
打开 id_rsa.pub
cat ~/.ssh/id_rsa.pub
网友评论