Mac SourceTree 连接 Github 设置指南

github授权方式改了,所以这个没用了,哈哈哈哈,需要另一种方法了

一定要记录下来,一连好几个礼拜,push和commit都是贼慢,大概push 10次才能成功一次,不是提示timeout,就是提示LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60,又或者提示最多的SSL_ERROR_SYSCALL in connection to github.com:443,终于今天被我搞定了!!!无论push还是commit都是秒成功!!!这种感觉实在是太爽了~~~~话不多说,直接正题~~解救同胞们,有效的话点个赞!

01. 思路

主要的思路就是本地生成ssh私钥和公钥,然后将公钥配置到github中,以便校验请求的可靠性

02 去代理

网上很多答案都是这个,不能说没用吧,只能说他们只做到了这一步,或者弄了各种host ip映射,麻烦的很,要是ip变了,到时候还需要改,反正我设置了没成功过。
个人习惯通过操作文件夹。终端输入

open ~/.gitconfig

去掉关于‘proxy’的,得到如图


image.png

03 生成ssh

名字随意,同时建议finder显示隐藏文件和扩展名
显示隐藏文件

defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder

显示扩展名:访达->偏好设置->高级->显示所有文件扩展名

ssh-keygen -t rsa -C "your email"   // 你的邮箱
==========以下步骤可以直接enter==========
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/.ssh/id_rsa): id_rsa  // 给生成生成私钥命名,自己写
Enter passphrase (empty for no passphrase):   // 设置输入密码,可以不设置直接下一步
Enter same passphrase again: 
Your identification has been saved in id_rsa. // 私钥
Your public key has been saved in id_rsa.pub. // 公钥
==========以上步骤可以直接enter==========
ssh-add ~/.ssh/id_rsa //将公钥添加到sousetree
ssh-add -K ~/.ssh/id_rsa //将公钥添加到钥匙串

验证是否成功

ssh -T [email protected] 
==========返回成功==========
Hi XXX! You've successfully authenticated, but Gitee.com does not provide shell 
access.

==========如果github上设置了公钥,则返回这样==========
The authenticity of host 'github.com (20.205.243.166)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? 

查看公密钥,可以看到如下,如果config,则新建一个

open ~/.ssh
image.png
# --- Sourcetree Generated ---
Host yqiang1000-GitHub(自己替换)
    HostName github.com
    User yqiang1000
    PreferredAuthentications publickey
    IdentityFile /Users/yeqiang/.ssh/yqiang1000-GitHub(路径别写错)
    UseKeychain yes
    AddKeysToAgent yes
# ----------------------------

04 Github上设置公钥

https://github.com/settings/keys,将公钥整个复制填充

05 完成

享受丝滑

你可能感兴趣的:(Mac SourceTree 连接 Github 设置指南)