Sådan konfigureres apt-get bag proxy-server til Ubuntu 14 / 15 / 16


Efter installation af Ubuntu 16.04 for at foretage nogle overvågningstest kunne jeg ikke få eller opdatere bag http / https / ftp proxyen. Her hvordan har jeg løst dette.

Jeg tror, ​​at denne løsning også skal fungere for Debian 7 / 8 og LinuxMint 16 / 17

min maskine:

ubuntu16

Forsøger at opdatere

root@ubuntu:~# apt-get  update
Err:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
  Could not resolve 'security.ubuntu.com'
Err:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease
  Could not resolve 'us.archive.ubuntu.com'
Err:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease
  Could not resolve 'us.archive.ubuntu.com'
Err:4 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease
  Could not resolve 'us.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Could not resolve 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
root@ubuntu:~#

Følg trinene bellow for at kunne udføre apt-get bag en proxy:

Opret ny conf tom fil inde i / etc / apt / og gør følgende

$ sudo vi /etc/apt/apt.conf

Tilføj denne linje til filen, hvis du bruger http proxy ellers https af ftp:

Acquire::http::Proxy "http://user:pass@proxy_host:port";

Or

Acquire::http::Proxy "http://Domainuser:pass@proxy_host:port";

Udfør nu proxylinjen med:

export http_proxy=http://user:pass@proxy_host:port

Or

export http_proxy=http://Domainuser:pass@proxy_host:port

For at gøre denne kommando permanent tilføj den til ~ / .Bash.rc i din hjemmekatalog:

vi ~ / .bash.rc

Kontroller og genstart opdateringerne nu:

root@ubuntu:~# apt-get  update
Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease [95.8 kB]
Hit:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease
Get:5 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1,442 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu xenial/main i386 Packages [1,437 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu xenial/main Translation-en [842 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [7,353 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu xenial/universe i386 Packages [7,343 kB]
53% [9 Packages 3,002 kB/7,343 kB 41%]

Opgrader nu:

root@ubuntu:~# apt-get  upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  ubuntu-minimal ubuntu-standard
2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,944 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 ubuntu-minimal amd64 1.349 [3,442 B]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 ubuntu-standard amd64 1.349 [3,502 B]
Fetched 6,944 B in 0s (21.9 kB/s)
(Reading database ... 87004 files and directories currently installed.)
Preparing to unpack .../ubuntu-minimal_1.349_amd64.deb ...
Unpacking ubuntu-minimal (1.349) over (1.348) ...
Preparing to unpack .../ubuntu-standard_1.349_amd64.deb ...
Unpacking ubuntu-standard (1.349) over (1.348) ...
Setting up ubuntu-minimal (1.349) ...
Setting up ubuntu-standard (1.349) ...
root@ubuntu:~#

At bruge wget bag proxy

sudo vi /etc/wgetrc

https_proxy  = http://username:password@proxy:port
http_proxy = http://username:password@proxy:port
http_proxy = http://Domainusername:password@proxy:port # (in case of LDAP)
ftp_proxy = http://username:password@proxy:port
Uncomment 'use_proxy = on'

Prøv nu at bruge wget

root@ubuntu:~# wget http://repo.zabbix.com/zabbix/2.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_2.4-1+trusty_all.deb
--2016-03-03 06:05:26--  http://repo.zabbix.com/zabbix/2.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_2.4-1+trusty_all.deb
Connecting to 10.133.80.35:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 2674 (2.6K) [application/x-debian-package]
Saving to: ‘zabbix-release_2.4-1+trusty_all.deb’

Husk dette en rigtig TEST bag en reel proxyserver med Domain / bruger og adgangskode.

God fornøjelse!

Giv en kommentar

Dette websted bruger Akismet til at reducere spam. Lær, hvordan dine kommentardata behandles.