linux通过内网代理,访问外网的常见配置

1.配置系统代理

如果临时设置系统代理,则每次ssh登录后,手动执行下面这段代码。如果需要永久使用代理,则编辑~/.bashrc,加入如下三行

export http_proxy=http://yourProxyIP:port
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy

wget相关配置

wget不需要单独配置代理,代理默认使用系统代理即可。

wget如需跳过检查证书,可以直接修改/etc/wgetrc,也可以在主文件夹下新建.wgetrc,并加入内容:

check_certificate = off

3.git代理及证书设置

3.1.配置git代理(以http代理为例)

使用默认系统代理的话,不需要单独配置git代理,如需只配置git代理,可通过如下命令设置

git config --global http.proxy http://<username>:<password>@<proxy.server.com>:<8080>
git config --global https.proxy http://<username>:<password>@<proxy.server.com>:<8080>

3.2.替换git协议为https协议

在有些企业的内网,由于git请求与ssh访问类似,防火墙会屏蔽git://协议的访问请求,如果git://无法访问,可尝试更换为https://协议

git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://

3.3.取消git访问https的证书验证

在有些企业访问外网的代理,会强行把https的证书进行替换,导致https访问时,出现证书错误。如果想跳过证书错误,需要把git全局的证书验证关闭。

git config --global http.sslVerify false
posted @ 2023-05-10 11:33  codeRhythm  阅读(1087)  评论(0编辑  收藏  举报