SourceTree自动登录设置SSH

今天帮同事设置SSH自动登录的时候,才发现自己没有写这方面的文章:

一、mac生成公钥,密钥

1. 进入ssh文件下

cd ~/.ssh

2. 生成ssh key

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

3. 提示输入目录,目录可以不填,有默认路径,直接回车

4. 提示输入密码, 密码可以不填,我个人推荐还是输入密码比较好的,严谨一点

Your identification has been saved in /Users/user/.ssh/id_rsa.

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

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxSourceTree二、自动登录设置SSH设置步骤如下

  1. cd 到  .ssh目录下, 用touch config命令创建config文件
  2. 执行open config, 打开config文件.
  3. 输入上面的配置内容, 保存·config文件
  4. 生成sshkey
  5. 执行ssh-add ~/.ssh/id_rsa 将sshkey添加到sourceTree《如果运行这个,显示权限过高,too open的话:先运行 chmod 400 ~/.ssh/id_rsa,再重新运行这行命令行》
  6. 执行ssh-add -K ~/.ssh/id_rsa 将sshkey添加到钥匙串

以后每次启动电脑source tree都会自动加载sshkey.

 

附加config文件内容:

========================config file content start=========================================

Host gitolite
 HostName IP name
 Port 20022
 User git
 IdentityFile ~\.ssh\general-dev1

========================config file content end=========================================

你可能感兴趣的:(笔记)