apt curl wget git 命令行临时设置代理

一、linux 代理全局设置

export http_proxy=http://192.168.6.9:8080/
export https_proxy=https://192.168.6.9:8080/ 可以
export https_proxy=http://192.168.6.9:8080/  也可以

缺点,有些工具不生效,每次要取消代理设置也麻烦



二、linux 命令行临时设置代理,推荐
apt

http proxy
sudo apt -o Acquire::http::proxy="192.168.6.9:8080/" install gcc
sudo apt -o Acquire::http::proxy="http://192.168.6.9:8080/" install gcc
https proxy
sudo apt -o Acquire::https::proxy="https://192.168.6.9:8080/" install gcc
SOCKS proxy
sudo apt -o Acquire::http::proxy="socks5h://192.168.6.9:8080/" install gcc
sudo apt -o Acquire::https::proxy="socks5h://192.168.6.9:8080/" install gcc

curl

curl -x http://192.168.6.9:8080 http://www.google.com
curl -x socks5h://192.168.6.9:8080 http://www.google.com
curl -k --proxy socks5h://192.168.6.9:8080 http://www.google.com
-x, --proxy [protocol://]host[:port] Use this proxy
-k, --insecure      Allow insecure server connections when using SSL

wget

wget -e use_proxy=yes -e http_proxy=http://192.168.6.9:8080 https://www.google.com
wget --no-check-certificate -e use_proxy=yes -e https_proxy=https://192.168.6.9:8080  https://www.google.com
wget不支持SOCKS代理,如下不行
wget -e "http_proxy=socks5h://localhost:2000"  https://google.com
wget -e "https_proxy=socks5h://localhost:2000"  https://google.com

git

export http_proxy=http://192.168.6.9:8080/
export https_proxy=http://192.168.6.9:8080/  可以
export https_proxy=https://192.168.6.9:8080/ 也可以
这样设置,git clone概率错误,需要git config https.proxy或者git config --global https.proxy

git config http.proxy 'http://192.168.6.9:8080'
git config https.proxy 'https://192.168.6.9:8080'
git config --global http.proxy 'http://192.168.6.9:8080'
git config --global https.proxy 'https://192.168.6.9:8080'

推荐下面三个
git -c http.proxy='http://192.168.6.9:8080' -c https.proxy='https://192.168.6.9:8080'  clone 

git -c http.proxy='socks5://192.168.6.9:8080' -c https.proxy='socks5://192.168.6.9:8080'  clone
git -c http.proxy='socks5h://192.168.6.9:8080' -c https.proxy='socks5h://192.168.6.9:8080' clone


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值