anygpu 发表于 2023-12-14 17:32:59

Ubuntu使用代理

本帖最后由 anygpu 于 2024-2-21 18:00 编辑

一、系统代理设置在/etc/profile.d/proxy.sh下添加一个shell脚本文件,这将确保设置适用于所有已登录的用户:sudo vim/etc/profile.d/proxy.sh将以下内容写到文档中:(将下面文档中的"http://10.10.1.10:8080/",替换为"http://x0Mds4hELw:71xxGZ1CTl@38.60.165.124:32091/"->该链接算力云平台学术资源加速专用)
使用socks协议也可。"socks5://anygpu:AnyGPU2024@38.60.165.124:12705/",地址: 38.60.165.124,端口: 12705,用户名:anygpu,密码:AnyGPU2024。
#set proxy config via profie.d - should apply for all users
export http_proxy="http://10.10.1.10:8080/"
export https_proxy="http://10.10.1.10:8080/"
export ftp_proxy="http://10.10.1.10:8080/"
export no_proxy="127.0.0.1,localhost"
# For curl
export HTTP_PROXY="http://10.10.1.10:8080/"
export HTTPS_PROXY="http://10.10.1.10:8080/"
export FTP_PROXY="http://10.10.1.10:8080/"
export NO_PROXY="127.0.0.1,localhost"为该文件填加执行权限:sudo chmod +x/etc/profile.d/proxy.sh激活文件以开始使用代理设置,或者注销并重新登录:
source /etc/profile.d/proxy.sh
#查看环境变量进行确认是否生效
env | grep -i proxy
#取消代理
unset http_proxy && unset https_proxy

二、 APT包管理器代理设置
以上设置适用于应用程序和命令行工具,如果只想为APT包管理器设置代理,请进行如下配置:
sudo vim /etc/apt/apt.conf.d/80proxy
#文档内容如下
Acquire::http::proxy "http://10.10.1.10:8080/";
Acquire::https::proxy "https://10.10.1.10:8080/";
Acquire::ftp::proxy "ftp://10.10.1.10:8080/";

#将10.10.1.10替换为代理服务器的正确IP地址,如果需要身份验证,请设置如下:

Acquire::http::proxy "http://<username>:<password>@<proxy>:<port>/";
Acquire::https::proxy "https://<username>:<password>@<proxy>:<port>/";
Acquire::ftp::proxy "ftp://<username>:<password>@<proxy>:<port>/";

三、Wget设置代理
要设置用于wget命令的代理设置,请将它们添加到~/.wgetrc文件中vim ~/.wgetrc
#写入内容:
use_proxy = on





页: [1]
查看完整版本: Ubuntu使用代理