字符终端设置代理

set http or socks proxy

复制代码
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
# set http proxy export http_proxy=http://127.0.0.1:8080 # set http proxy with user and password export http_proxy=http://USERNAME:PASSWORD@127.0.0.1:8080 # set http proxy with user and password (with special characters) export http_proxy=http://`urlencode 'USERNAME'`:`urlencode 'PASSWORD'`@127.0.0.1:8080 # set socks proxy (local DNS) export http_proxy=socks5://127.0.0.1:1080 # set socks proxy (remote DNS) export http_proxy=socks5h://127.0.0.1:1080
复制代码
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
# export other env variables export https_proxy=$http_proxy \ ftp_proxy=$http_proxy \ rsync_proxy=$http_proxy \ all_proxy=$http_proxy # export other env variables (another way) export {https,ftp,rsync,all}_proxy=$http_proxy export HTTP_PROXY=$http_proxy \ HTTPS_PROXY=$http_proxy \ FTP_PROXY=$http_proxy \ RSYNC_PROXY=$http_proxy \ ALL_PROXY=$http_proxy \ NO_PROXY=$no_proxy export {HTTP,HTTPS,FTP,RSYNC,ALL}_PROXY=$http_proxy # set git http(s) proxy git config --global http.sslverify false git config --global http.proxy $http_proxy git config --global https.proxy $http_proxy # only for 'github.com' git config --global http.https://github.com.proxy $http_proxy

set ssh proxy

复制代码
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
# use 'nc' with http protocol export ssh_proxy='ProxyCommand=nc -X connect -x PROXYHOST:PROXYPORT %h %p' # use 'nc' with socks5 protocol export ssh_proxy='ProxyCommand=nc -X 5 -x PROXYHOST:PROXYPORT %h %p' # use 'connect' with http protocol export ssh_proxy='ProxyCommand=connect -H PROXYHOST:PROXYPORT %h %p' # use 'connect' with socks5 protocol export ssh_proxy='ProxyCommand=connect -S PROXYHOST:PROXYPORT %h %p' # connect to ssh server over proxy ssh -o "$ssh_proxy" USER@FINAL_DEST

set no proxy to ignore private network address

复制代码
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
no_proxy="127.0.0.1,localhost,.localdomain.com" no_proxy=$no_proxy,`echo 10.{0..255}.{0..255}.{0..255}|tr ' ' ','` no_proxy=$no_proxy,`echo 172.{16..31}.{0..255}.{0..255}|tr ' ' ','` no_proxy=$no_proxy,`echo 192.168.{0..255}.{0..255}|tr ' ' ','` export no_proxy # for more private network addresses, check following url # https://segmentfault.com/q/1010000010521593 # https://en.wikipedia.org/wiki/Private_network

unset proxy

复制代码
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
unset http_proxy https_proxy ftp_proxy rsync_proxy all_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY RSYNC_PROXY ALL_PROXY unset {http,https,ftp,rsync,all}_proxy {HTTP,HTTPS,FTP,RSYNC,ALL}_PROXY git config --global --unset http.proxy git config --global --unset https.proxy git config --global --unset http.https://github.com.proxy unset ssh_proxy
posted @   heyb7  阅读(126)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
展开