生成SSH
创建SSH,在终端中执行ssh-keygen -t rsa -C "youremail@example.com",会在.ssh目录下生成id_rsa、id_rsa.pub两个私钥和公钥。
cd到~/.ssh目录下 执行ls命令查看是否创建成功
通过cat ~/.ssh/id_rsa.pub查看公钥,并将公钥整体复制,配置到GitHub等后台。
配置本地SSH
执行ssh-add ~/.ssh/id_rsa将sshkey添加到sourceTree
执行ssh-add -K ~/.ssh/id_rsa将sshkey添加到钥匙串
cd 到 .ssh目录下, 用touch config命令创建config文件
执行open config, 打开config文件,输入以下内容并保存
Host *
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa