【随笔记】MacOS系统下设置Git及配置代理详细记录

绣文字

关注

阅读 129

2022-02-18

生成 ssh 秘钥对

# 生成 ssh 秘钥对,一路回车
$ ssh-keygen -t rsa

# 查看公钥
$ cat ~/.ssh/id_rsa.pub

配置用户名 邮箱

# 设置用户名
$ git config --global user.name "your name"

# 设置密码
$ git config --global user.email "your email"

Windows 代理设置

1.安装git找到安装目录下的ssh_config文件

x64 C:\Program Files\Git\etc\ssh

x86 C:\Program Files(x86)\Git\etc\ssh

2.添加配置如下

Host ServerIP

IdentityFile “~/.ssh/id_rsa”

ProxyCommand /mingw64/bin/connect.exe -H ProxyIP:ProxyPort %h %p

MacOS Linux 设置代理

  1. 安装 connect
# 下载 connect 源码
$ git clone https://github.com/moonagic/connect.git

# 编译 connect 源码
$ cd connect && make

# 将编译后的 connect 二进制文件拷贝到 bin 目录
$ cp connect /usr/local/bin
  1. 修改 ~/.ssh/config 如下
# ServerIP Git服务器IP
# ProxyIP:ProxyPort 代理服务器IP与Port
Host ServerIP
  IdentityFile "~/.ssh/id_rsa"
  ProxyCommand connect -H ProxyIP:ProxyPort %h %p

精彩评论(0)

0 0 举报