Files
CmiiDeploy/998-常用脚本/设置apt走代理.md
zeaslity 437acbeb63 add
2024-10-30 16:30:51 +08:00

37 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

要在Ubuntu上使用代理服务器来进行apt操作可以按照以下步骤进行配置
1. 打开终端,并进入`/etc/apt`目录:
```shell
cd /etc/apt
```
2. 创建一个新的文件或编辑已有的文件,例如`apt.conf.d/99proxy`
```shell
sudo nano apt.conf.d/99proxy
```
3. 在打开的文件中添加以下内容,将代理服务器的地址和端口替换为实际的代理服务器信息:
```shell
Acquire::http::Proxy "http://proxy-server-address:proxy-port";
Acquire::https::Proxy "http://proxy-server-address:proxy-port";
```
4. 保存并关闭文件使用Ctrl + X然后按Y确认保存
5. 现在您可以尝试运行任何apt命令例如更新软件包列表
```shell
sudo apt update
```
注意如果代理服务器需要用户名和密码进行身份验证您还需要添加额外的配置。在步骤3中将http和https行更改为如下所示并替换`username`和`password`为实际的凭据:
```shell
Acquire::http::Proxy "http://username:password@proxy-server-address:proxy-port";
Acquire::https::Proxy "http://username:password@proxy-server-address:proxy-port";
```
这样就完成了在Ubuntu上使用代理服务器进行apt操作的配置。确保替换`proxy-server-address`和`proxy-port`为实际的代理服务器地址和端口,并根据需要进行身份验证的配置。
```shell
Acquire::http::Proxy "http://192.168.8.102:10811";
Acquire::https::Proxy "http://192.168.8.102:10811";
```