VirtualBox Ubuntu でプロキシの背後に apt-get を実行する

VirtualBox Ubuntu でプロキシの背後に apt-get を実行する

プロキシの背後で apt-get が動作するように設定するにはどうすればよいですか?

答え1

http_proxy="http://host:port" apt-get something

動作するはずです。

認証が必要な場合は、

http_proxy="http://user:pass@host:port" apt-get something

これを永続的にしたい場合は、~/.bashrcプロキシ対応アプリケーション (例: 'wget') がすべて将来動作するように、http_proxy (および ftp_proxy?) 変数を設定する必要があります。

答え2

/etc/apt/apt.conf に次の行を追加します。

Acquire::http::Proxy "http://MYDOMAIN\MYNAME:[email protected]:MYPORT"

から:http://ubuntuforums.org/showthread.php?t=96802

(注:完全に盗用この答えSFでの同様の質問に。グリズリー

答え3

プロキシはhttp_proxy、、ftp_proxyおよびall_proxy環境変数をローカル( など~/.bashrc)またはグローバル( など/etc/bash.bashrc)に設定することによって指定されます。これらの設定は、ほぼすべてのネット ソフトウェア パッケージ(apt-get、wget、curl など)で尊重されます。

# HTTP proxy without authentification
export http_proxy="http://host:port"
# HTTP proxy with authentification
export http_proxy="http://user:pass@host:port"

ただし、このように設定しても実行時には役に立ちませんsudo apt-get ...。これは、次の行が原因です/etc/sudoers:

Defaults env_reset

この行リセットsudoセキュリティ上の理由から、を使用する際にはすべての環境変数を保つhttp_proxy呼び出し時の などの値については、 を介してsudo例外を指定できます。env_resetenv_keep

# Exception specific to the command apt-get
Defaults!/usr/bin/apt-get env_keep="http_proxy https_proxy ftp_proxy"
# Exception specific to the user joe
Defaults:joe env_keep="http_proxy https_proxy ftp_proxy"

apt-getこうすることで、グローバルapt-get難解な apt 固有の設定ファイルで設定を複製する代わりに、http_proxy の設定を使用します。

関連情報