文章目录
1.查看本地是否存在SSH Key
终端:ls -al ~/.ssh
若id_rsa和id_rsa.pub存在,证明本地已经存在SSH密钥,跳转步骤3
2.生成SSH Key
生成:ssh-keygen -t rsa -C “emAIl@xxx.com”
生成成功会提示以下代码
Generating public/private rsa key pAIr.
Enter file in which to save the key (/Users/xxx/.ssh/id_rsa):
之后会提示你保存.ssh/id_rsa文件路径,直接enter即可
Created directory ‘/Users/xxx/.ssh’.
Enter passphrase (empty for no passphrase):
然后会提示你输入密码,两次.因为输入密码以后进行操作的时候都需要输入密码,所以最好不输入,直接enter,成功之后会显示
添加:ssh-add ~/.ssh/id_rsa
此时会要求输入密码,之前输入了密码,此时就再次输入,没输入就enter
成功之后终端会显示以下命令
Identity added: /Users/xxx/.ssh/id_rsa (/Users/xxx/.ssh/id_rsa)
最后会在.ssh文件夹下生成两个文件,一个是id_rsa,另一个是id_rsa.push到这一步,ssh已经生成成功