Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iTerm2终端使用代理 && SSH(git) 代理 #30

Open
monsterooo opened this issue Dec 1, 2018 · 0 comments
Open

iTerm2终端使用代理 && SSH(git) 代理 #30

monsterooo opened this issue Dec 1, 2018 · 0 comments
Labels

Comments

@monsterooo
Copy link
Owner

monsterooo commented Dec 1, 2018

iTerm2终端配置代理

  1. 找到代理地址:127.0.0.1:50880

  2. 修改~/.bash_profile配置文件入下:

# proxy
export http_proxy=http://127.0.0.1:50880
export https_proxy=$http_proxy

如果不存在 ~/.bash_profile 则新建一个

  1. 执行 source 命令让配置文件立刻生效,source ~/.bash_profile

  2. 测试是否链接 curl -i https://google.com

ssh 代理

以上设置只针对http(s)的协议,如果clone的git仓库地址是git协议开头的,则无法使用代理速度还是非常非常的慢(6k~12k)。

配置代理后的效果:

image

这个时候需要配置ssh的代理(git协议是特殊的协议它走的是ssh的通道)

具体配置ssh的方法:

编辑 ~/.ssh/config,没有则创建一个

Host github.com
    User git
    ProxyCommand /usr/bin/nc -X 5 -x <socks_host>:<socks_port> %h %p

git特殊协议代理方法(我测试无效)

配置git配置(~/.gitconfig)

[core]
    gitproxy = /path/to/gitproxy for github.com

或使用命令更新git配置项:git config --global core.gitproxy "/path/to/gitproxy for github.com"

代理脚本:

#!/bin/sh
#
# Proxy wrapper for git protocol (9418).
#
# git config --global core.gitproxy "ido gitproxy"
#
exec /usr/bin/nc -X 5 -x <socks_host>:<socks_port> $1 $2

参考来源:https://yechengfu.com/blog/2015/01/16/use-git-behind-proxy/

@monsterooo monsterooo changed the title iTerm2终端使用代理 iTerm2终端使用代理 && SSH 代理 Jul 30, 2019
@monsterooo monsterooo changed the title iTerm2终端使用代理 && SSH 代理 iTerm2终端使用代理 && SSH(git) 代理 Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant