如何连接到 Ubuntu Studio 上的代理?

如何连接到 Ubuntu Studio 上的代理?

所以我在笔记本电脑上运行 Ubuntu Studio,我该怎么做才能连接到代理?我搜索代理,但在网络设置中没有 PROXY 选项卡。在选项卡中要查找的关键词是什么?

答案1

我写了一个脚本来响应Unix 和 Linux 上的问题关于设置代理:

#! /bin/bash
HTTP_PROXY_HOST="proxy.example.com"
HTTP_PROXY_PORT=3128
HTTPS_PROXY_HOST="proxy.example.com"
HTTPS_PROXY_PORT=3128

gsettings set org.gnome.system.proxy mode manual
gsettings set org.gnome.system.proxy.http host "$HTTP_PROXY_HOST"
gsettings set org.gnome.system.proxy.http port "$HTTP_PROXY_PORT"
gsettings set org.gnome.system.proxy.https host "$HTTPS_PROXY_HOST"
gsettings set org.gnome.system.proxy.https port "$HTTPS_PROXY_PORT"

sudo sed -i.bak '/http[s]::proxy/Id' /etc/apt/apt.conf
sudo tee -a /etc/apt/apt.conf <<EOF
Acquire::http::proxy "http://$HTTP_PROXY_HOST:$HTTP_PROXY_PORT/";
Acquire::https::proxy "http://$HTTPS_PROXY_HOST:$HTTPS_PROXY_PORT/";
EOF

sudo sed -i.bak '/http[s]_proxy/Id' /etc/environment
sudo tee -a /etc/environment <<EOF
http_proxy="http://$HTTP_PROXY_HOST:$HTTP_PROXY_PORT/"
https_proxy="http://$HTTPS_PROXY_HOST:$HTTPS_PROXY_PORT/"
EOF

保存到文件(称为proxy.sh),使用您最喜欢的编辑器编辑它以设置变量的值*_PROXY_*并运行:

chmod +x proxy.sh
./proxy.sh

据我所知,它的功能与 GUI 完全相同(如果基于 GNOME 环境,即 Ubuntu Studio)。

答案2

您可以通过终端设置您的代理。

为此,您应该编辑以下文件:

/etc/bash.bashrc
/etc/environment
/etc/apt/apt.conf
/usr/local/etc/freshclam.conf 

这些文件必须包含以下内容:

    sudo -i
    nano  /etc/bash.bashrc
  ------------------------------------------------------------------ 
    export http_proxy=http://username:[email protected]:port/
    export https_proxy=http://username:[email protected]:port/
    export ftp_proxy=http://username:[email protected]:port/
  ------------------------------------------------------------------

Control + O,保存文件。

    sudo -i
    nano  /etc/environment
   ----------------------------------------------------------
    http_proxy=http://username:[email protected]:port/
    https_proxy=http://username:[email protected]:port/
    ftp_proxy=http://username:[email protected]:port/
   ----------------------------------------------------------

Control + O,保存文件。

    sudo -i
    nano /etc/apt/apt.conf
    --------------------------------------------------------------------
    Acquire::http::Proxy "http://username:[email protected]:port";
    Acquire::https::Proxy "http://username:[email protected]:port";
    Acquire::ftp::Proxy "http://username:[email protected]:port";
    ---------------------------------------------------------------------

Control + O,保存文件。

    sudo -i
    nano  /usr/local/etc/freshclam.conf 
    -------------------------------- 
    HTTPProxyServer proxyserver.net
    HTTPProxyPort port
    HTTPProxyUsername username
    HTTPProxyPassword password
    --------------------------------

Control + O,保存文件。Control + X,关闭 nano

相关内容