diff --git a/sources/tech/20230422.0 ⭐️ How to Set Proxy Settings for APT Command.md b/sources/tech/20230422.0 ⭐️ How to Set Proxy Settings for APT Command.md deleted file mode 100644 index e4031aef2e..0000000000 --- a/sources/tech/20230422.0 ⭐️ How to Set Proxy Settings for APT Command.md +++ /dev/null @@ -1,139 +0,0 @@ -[#]: subject: "How to Set Proxy Settings for APT Command" -[#]: via: "https://www.linuxtechi.com/set-proxy-settings-for-apt-command/" -[#]: author: "James Kiarie https://www.linuxtechi.com/author/james/" -[#]: collector: "lkxed" -[#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -How to Set Proxy Settings for APT Command -====== - -In this guide, you will learn how to set proxy settings for the APT command in Ubuntu/Debian Linux distributions. - -A proxy server is an intermediary server that sits between a client system or end user requesting the resource and the resource itself. In most cases, a proxy server acts as a gateway between end users and the internet. - -For organizations and enterprise environments, a proxy server provides a number of benefits. It controls internet usage by blocking sites that are deemed to impact employees’ productivity. It also enhances privacy and improves the organization’s security through data encryption. - -There are several ways to set proxy settings for apt command, so let’s jump right in. - -Note: For demonstration, we will use Ubuntu 22.04. - -### Configure Proxy Setting For APT Using A Proxy file - -The easiest way to configure proxy settings for the APT command is by creating a proxy.conf file as shown. - -``` -$ sudo vi /etc/apt/apt.conf.d/proxy.conf -``` - -For a proxy server without a username and password, add the following entries as shown - -For the HTTP Proxy, add the following entry: - -``` -Acquire::http::Proxy "http://proxy-IP-address:proxyport/"; -``` - -Do the same for the  HTTPS Proxy: - -``` -Acquire::https::Proxy "http://proxy-IP-address:proxyport/"; -``` - -Example: - -``` -$ cat  /etc/apt/apt.conf.d/proxy.conf -Acquire::http::Proxy "http://192.168.56.102:3128/"; -Acquire::https::Proxy "http://192.168.56.102:3128/"; -``` - -If your Proxy server requires a username and password details, add them as follows - -``` -Acquire::http::Proxy "http://username:[email protected]:proxyport"; -Acquire::https::Proxy "http://username:[email protected]:proxyport"; -``` - -Example: - -``` -$ cat  /etc/apt/apt.conf.d/proxy.conf -Acquire::http::Proxy "http://[email protected]#@192.168.56.102:3128/"; -Acquire::https::Proxy "http://[email protected]#@192.168.56.102:3128/"; -``` - -Once you are done, Save the changes and exit the configuration file. The Proxy settings will come into action the next time you run the APT package manager. - -For example, you can update the local package index and then install net-tools package - -``` -$ sudo apt update -$ sudo apt install net-tools -y -``` - -Verify the proxy server logs to confirm that apt command is using proxy server for downloading packages. On the proxy server run, - -``` -# tail -f /var/log/squid/access.log  | grep -i 192.168.56.240 -``` - -Here ‘192.168.56.240’ is the IP address of our Ubuntu machine, - -Perfect, output above confirms that apt command of our ubuntu system is downloading the packages via proxy server (192.168.56.102) - -### An Alternative Way of Specifying Proxy Details - -Apart from the first approach, you can specify the proxy details in a much simpler way. Once again, create a proxy.conf file as follows. - -``` -$ sudo vi /etc/apt/apt.conf.d/proxy.conf -``` - -For a Proxy server without a username and password, define it as shown. - -``` -Acquire { -  http::Proxy "http://proxy-IP-address:proxyport/"; -  https::Proxy "http://proxy-IP-address:proxyport/"; -} -``` - -Sample example file would look like below, - -``` -$ sudo vi /etc/apt/apt.conf.d/proxy.conf -``` - -For a Proxy server with username and login details: - -``` -Acquire { - http::Proxy "http://username:[email protected]:proxyport/"; - https::Proxy "http://username:[email protected]:proxyport/"; -} -``` - -Save the changes and exit the configuration file. Just a reminder that these settings take immediate effect once you start using the APT package manager. - -##### Conclusion - -This concludes this guide. In this tutorial, we have demonstrated how you can configure proxy settings for the APT package manager which is used in Debian/Ubuntu Linux distributions. That’s all for now. Keep it Linuxechi! - -Also Read: How to Install Go (Golang) on Ubuntu Linux Step-by-Step - --------------------------------------------------------------------------------- - -via: https://www.linuxtechi.com/set-proxy-settings-for-apt-command/ - -作者:[James Kiarie][a] -选题:[lkxed][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.linuxtechi.com/author/james/ -[b]: https://github.com/lkxed/ diff --git a/translated/tech/20230422.0 ⭐️ How to Set Proxy Settings for APT Command.md b/translated/tech/20230422.0 ⭐️ How to Set Proxy Settings for APT Command.md new file mode 100644 index 0000000000..d0ffe1d3da --- /dev/null +++ b/translated/tech/20230422.0 ⭐️ How to Set Proxy Settings for APT Command.md @@ -0,0 +1,146 @@ +[#]: subject: "How to Set Proxy Settings for APT Command" +[#]: via: "https://www.linuxtechi.com/set-proxy-settings-for-apt-command/" +[#]: author: "James Kiarie https://www.linuxtechi.com/author/james/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +如何为 APT 命令设置代理 +====== + +在本指南中,你将了解如何在 Ubuntu/Debian Linux 发行版中为 APT 命令设置代理。 + +代理服务器是位于请求资源的客户端系统或最终用户与资源本身之间的中间服务器。在大多数情况下,代理服务器充当最终用户和互联网之间的网关。 + +对于组织和企业环境,代理服务器提供了许多好处。它通过阻止被认为会影响员工工作效率的网站来控制互联网的使用。它还通过数据加密增强隐私并提高组织的安全性。 + +有几种方法可以为 apt 命令设置代理,让我们直接进入。 + +注意:为了演示,我们将使用 Ubuntu 22.04。 + +### 使用代理文件为 APT 配置代理 + +为 APT 命令配置代理的最简单方法是创建一个 proxy.conf 文件,如图所示。 + +``` +$ sudo vi /etc/apt/apt.conf.d/proxy.conf +``` + +对于没有用户名和密码的代理服务器,添加以下条目,如图所示。 + +对于 HTTP 代理,添加以下条目: + +``` +Acquire::http::Proxy "http://proxy-IP-address:proxyport/"; +``` + +对 HTTPS 代理执行相同的操作: + +``` +Acquire::https::Proxy "http://proxy-IP-address:proxyport/"; +``` + +例子: + +``` +$ cat /etc/apt/apt.conf.d/proxy.conf +Acquire::http::Proxy "http://192.168.56.102:3128/"; +Acquire::https::Proxy "http://192.168.56.102:3128/"; +``` + +如果你的代理服务器需要用户名和密码详细信息,请按以下方式添加: + +``` +Acquire::http::Proxy "http://username:[email protected]:proxyport"; +Acquire::https::Proxy "http://username:[email protected]:proxyport"; +``` + +例子: + +``` +$ cat /etc/apt/apt.conf.d/proxy.conf +Acquire::http::Proxy "http://[email protected]#@192.168.56.102:3128/"; +Acquire::https::Proxy "http://[email protected]#@192.168.56.102:3128/"; +``` + +完成后,保存更改并退出配置文件。代理设置将在你下次运行 APT 包管理器时生效。 + +例如,你可以更新本地包索引,然后安装 net-tools 包: + +``` +$ sudo apt update +$ sudo apt install net-tools -y +``` + +![][1] + +验证代理服务器日志以确认 apt 命令正在使用代理服务器下载包。在代理服务器运行时: + +``` +# tail -f /var/log/squid/access.log | grep -i 192.168.56.240 +``` + +这里 “192.168.56.240” 是我们 Ubuntu 机器的 IP 地址。 + +![][2] + +完美,上面的输出确认我们的 ubuntu 系统的 apt 命令正在通过代理服务器 (192.168.56.102) 下载包。 + +### 另一种指定代理详细信息的方法 + +除了第一种方法,你还可以用更简单的方式指定代理详细信息。再次创建一个 proxy.conf 文件,如下所示。 + +``` +$ sudo vi /etc/apt/apt.conf.d/proxy.conf +``` + +对于没有用户名和密码的代理服务器,如图所示进行定义。 + +``` +Acquire { + http::Proxy "http://proxy-IP-address:proxyport/"; + https::Proxy "http://proxy-IP-address:proxyport/"; +} +``` + +示例文件如下所示: + +``` +$ sudo vi /etc/apt/apt.conf.d/proxy.conf +``` + +![][3] + +对于具有用户名和登录详细信息的代理服务器: + +``` +Acquire { + http::Proxy "http://username:[email protected]:proxyport/"; + https::Proxy "http://username:[email protected]:proxyport/"; +} +``` + +保存更改并退出配置文件。提醒一下,当你开始使用 APT 包管理器,这些设置就会立即生效。 + +##### 总结 + +本指南到此结束。在本教程中,我们演示了如何为 Debian/Ubuntu Linux 发行版中使用的 APT 包管理器配置代理设置。目前为止就这样了。继续关注 Linuxechi! + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/set-proxy-settings-for-apt-command/ + +作者:[James Kiarie][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/james/ +[b]: https://github.com/lkxed/ +[1]: https://www.linuxtechi.com/wp-content/uploads/2023/04/Apt-Install-Package-Proxy-Settings-1024x403.png?ezimgfmt=ng:webp/ngcb22 +[2]: https://www.linuxtechi.com/wp-content/uploads/2023/04/Grep-Proxy-Logs-Ubuntu-Machine-1024x326.png?ezimgfmt=ng:webp/ngcb22 +[3]: https://www.linuxtechi.com/wp-content/uploads/2023/04/Proxy-conf-Apt-Command-Ubuntu.png \ No newline at end of file