How do i connect APT and Software Centre behind a Proxy?! (Linux – Ubuntu 11.04+, Mint 10+)

Here is another great fix that I found in my daily struggles…

Here in my office, like most other corporate environments, we are behind a proxy server.  This is simply a security and management resource used by many businesses both large and small.  With most Windows machines, this is not a very large hurdle since there is only one place to change proxy settings and everything sort of, “comes together”.

Linux, on the other hand, is a bit different.  There is the normal web browser proxy settings that most would find in a comparable system but there is also something called APT or YUM which is sort of a direct connection to update servers.  The problem with this is that APT does not utilize or care about the proxy settings that you just put into Firefox.

Here is a quick rundown of what I’ve found out….

There are certain operating procedures in Linux that use multiple files in succession much like a bootable drive list.

example.

10usb     20cdrom     30harddrive     40hardrive2

When the operating system sees this type of hierarchy, it knows to follow this like literal instructions.  Read file 1, if conditions are met, stop.  If conditions are not met, continue to second string.

In Ubuntu Linux and Linux Mint, APT also uses this type of “recipe.”

If you look in, /etc/apt/apt.conf.d, you will see

00trustcdrom   15update-stamp     20dbus     50unattended upgrades 

01autoremove     20archive     70debconf     10periodic     20changelog     99update-notifier

Here is the procedure to work with and around this system…

1. Open a terminal session and log in as a root user (from the terminal prompt, type sudo -i, you will then be prompted to login with your sudo password)

2. From the root prompt, (root@ubuntu:~#), type cd ../etc/apt/apt.conf.d

3. You should now see root@ubuntu:/etc/apt/apt.conf.d#

4. Type gedit 30proxy

5.  This will open a new “GEdit” window with a blank page.

6.  In this window, type:


Acquire::http::proxy "http://proxy.yourproxy.yourcompany.com:8080/";
Acquire::ftp::proxy "ftp://proxy.yourproxy.yourcompany.com:8080/";
Acquire::https:proxy "https://proxy.yourproxy.yourcompany.com:8080/";


Where it says “YOURPROXYADDRESS:YOURPORTNUMBER”, make sure you change that to the correct information.  For example, if your proxy is “http://proxy.google.com” and it uses port “8080”, then you will type “Acquire::http::Proxy”http://proxy.google.com:8080/”;”

7. From this point, select the save button at the top of the window and close out of all applications.

8.  Open a new terminal window and simply type sudo apt-get update

9.  You will once again be prompted for your password and you should see the update start downloading.

If this seems a little tricky and you need a hand, feel free to comment here and I will do my best to answer quickly.

Cheers,

The Guru

 

Advertisements

7 thoughts on “How do i connect APT and Software Centre behind a Proxy?! (Linux – Ubuntu 11.04+, Mint 10+)

  1. Having the exact same issue – tried your solution but get a syntax error-

    Syntax error /etc/apt/apt.conf.d/30proxy:4: Extra junk at end of file

    Hope you can help.

    Thanks for the post either way though.

    Steve (new to cli and ubuntu)

      1. Hi!

        I left my workstation at work…. but I am running Ubuntu 11.04.

        When I run sudo apt-get update I get the “Syntax error…….Extra junk” as above. Checked to see if there was any white spaces or anything but nothing – when I get back to work I will check again and copy the whole error.

        Been struggling to update through the Update Centre and through apt for a while – glad I am not the only one.

        Cheers

        Steve

  2. THANK YOU! Confirmed on Mint 14.

    As for the person reporting the problem with “extra junk at the end of the file”, I encountered the same error; I forgot to end the lines with a semicolon.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s