mac下使用SSH克隆git上的代码

1、打开你公司的git账号,左边目录会有一个钥匙串,然后点击,会有一个SSH配置教程,点击即可看到这个界面,然后打开终端

《mac下使用SSH克隆git上的代码》

2、在终端中直接输入以下命令

——————————————————————————–

$ssh-keygen -t rsa -C${YourEmail}”                                       # “-t rsa”表示使用密钥的加密类型,还可以为dsa;-C设置注释文字,比如你的邮箱“YourEmail”,不一定要是github注册邮箱
Enter file in which to save the key (/Users/faner/.ssh/id_rsa):   # 直接回车
Enter passphrase (empty for no passphrase):                            # 输入密钥文件授权密码
Enter same passphrase again:                                                    # 确认密钥文件授权密码
Your identification has been saved in /Users/faner/.ssh/id_rsa.

Your public key has been saved in /Users/faner/.ssh/id_rsa.pub.

——————————————————————————–

3、id_rsa私钥类似keychain进行CSR时生成的private key;id_rsa.pub公钥则类似CSR申请下来的开发证书(在Apple Member Center中有在线备案)。
cat id_rsa.pub  或者 pbcopy < ~/.ssh/id_rsa.pub(此命令直接复制了公钥内容,直接可以使用)        #查看公钥内容 

                           

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChNZLq33LwvBr+QJfrdYrHA8SIDFcfw3H2vr0uJbK+erGLal32u/JJFYUf4jMIHhFLiF/J2TbpVuAa7r9/eNyjWw8M3ptoWlJq8Sw7tHU8me80Whklr771wjKt8HVX/1Ck7evZ0OcqsdosucKXdtUQgxDXV7wMdGhTdmjxqpuwqeI53gPxuFR0TNm5ROidD5yzsJYcI7HGNj7F0OPthgebl/x/deNQlUNiUhiAE0CJ/qu5EIprw9qUbgvQuDSrJhAPUuGY9x9jkHP7aTa784zZz10rpaR4nX/T0M7mwFgHicM/+O5F/y2wXwNrzDnhhGPYfMBmzQOuJG4c84fjVuOL YourEmail.com

4、将公要内容复制,点击Add SSH Key 按钮,在Key文本框将此内容粘贴, Title命一个名字进行区分

《mac下使用SSH克隆git上的代码》

这时看到添加成功了一个配置 

《mac下使用SSH克隆git上的代码》 

5、本机通过ssh-keygen生成公钥后,执行ssh -T git@github.com

The authenticity of host ‘gitlab2..com (192.168.20.100)’ can’t be established.
RSA key fingerprint is SHA256:qKZZrX7I9GM/aX4JWh7upbgiLa7fYZidz8+HnA6151I.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘gitlab2.xiniunet.com,192.168.20.100’ (RSA) to the list of known hosts.
Welcome to GitLab, zhangming!

在本地创建一个文件夹执行  git clone git@gitlab2.xxxxxxx.git 命令,验证是附配置成功

博主提供一篇讲解比较全的博客

Mac下git通过SSH进行免密码安全连接github

    原文作者:MinggeQingchun
    原文地址: https://blog.csdn.net/MinggeQingchun/article/details/51775416
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞