Sourcetree 配置 SSH

我们先切换目录。cd ~/.ssh/,如果报错,则新建。

cd ~/.ssh/ 
#mkdir ~/.ssh  //新建

接着按下面命令来生成 sshkey:

ssh-keygen -t rsa -C "[email protected]"

按照提示完成三次回车(key直接回车会默认是id_isa,设置密码为空),即可生成 ssh key

**下一步非常重要:在.ssh 中添加config文件 输入对应的host信息

cd ~/.ssh
touch config

执行open config 打开config文件 然后输入一下内容保存

Host *
   UseKeychain yes
   AddKeysToAgent yes
   IdentityFile ~/.ssh/id_rsa
   IdentityFile ~/.ssh/github_rsa

然后,我们就可以配置,Git 的全局用户名和邮箱了。jie
cat id_rsa.pub
复制 接下来登录git--profile Setting--ssh keys

git config --global user.name "yourname"

git config --global user.email "youremail"
#HostkeyAlgorithms +ssh-dss

Host git.xxxxx.com

HostName git.xxxxxx.com

PubkeyAcceptedKeyTypes +ssh-dss

HostkeyAlgorithms +ssh-dss

 IdentityFile ~/.ssh/id_rsa

Host git.coding.net

HostName git.coding.net

PreferredAuthentications publickey

User [email protected]

IdentityFile ~/.ssh/id_rsa

你可能感兴趣的:(Sourcetree 配置 SSH)