sourceTree配置ssh key

2018-10-17  本文已影响0人  吖蛋黄

一、使用 git 客户的生成公私钥:id_rsa、id_rsa.pub

1、设置Git的user name和email

$ git config --global user.name "xxx"
$ git config --global user.email "xxx.mail@xxx.com"

2、检查是不是已经存在密钥(能进去说明已经存在,就删掉文件夹,重新创建):

cd ~/.ssh

3、生成 SSH 密钥,打开命令行终端输入ssh-keygen -t rsa -C <your_email@example.com>( 你的邮箱),连续点击 Enter 键即可。

C:\Users\HASEE>ssh-keygen -t rsa -C "danhuanhong@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\HASEE/.ssh/id_rsa):// 推荐使用默认地址
Created directory 'C:\Users\HASEE/.ssh'.
Enter passphrase (empty for no passphrase)://此处点击 Enter 键即可,也可以填写密码,填写密码后每次使用 SSH 方式推送代码时都会要求输入密码,由于这个 Key 也不是用于军事目的,所以也无需设置密码。
Enter same passphrase again:
image.png
image.png

二、设置 SourceTree 的 SSH客户端

1、配置SourceTree 的 SSH 客户的为:OpenSSH
1.1 工具->选项


image.png

1.2 SSH客户端配置,选择OpenSSH


image.png

三、coding项目里面,部署公钥>新建部署公钥,把C:\Users\HASEE.ssh\id_rsa.pub的内容复制到公钥内容中。

第一种:全局秘钥,对账号的所有项目有效

image.png
image.png

第二种:项目秘钥,只对改项目有效

image.png image.png

四、配置好SSH秘钥后,拉取项目时,注意选择SSH协议的链接。

image.png

五、成功

image.png
上一篇 下一篇

猜你喜欢

热点阅读