How do you know that you apt-get command encounter proxy issue, when ypu received "401 authenticationrequired" error after running your apt-get command, like below:
$ sudo apt-get update ... W: Failed to fetch http://my.archive.ubuntu.com/ubuntu/dists/raring-updates/universe/binary-i386/Packages 401 authenticationrequired ...
How to encounter this?
Method 1 (if you have GUI)
- Simply open your browser, and the proxy will ask for authentication
- Fill up your authentication.
- Rerun your apt-get command
Method 2 (if you have GUI)
- Go to System -> preferences -> Network Proxy
- Under Proxy Configuration, put in you proxy details
- Rerun apt-get
Method 3 (without GUI) - temporary proxy session
- export the http_proxy environment variable using this command:
$ sudo export http_proxy='http://myusername:mypassword@myproxyaddress:myproxyport'
- Rerun apt-get
Method 4 (without GUI) - temporary proxy session
- run the apt-get command with proxy in one line:
$ sudo bash -c 'http_proxy="http://myusername:mypassword@myproxyaddress:myproxyport/" apt-get update'
Method 5 (without GUI) - permanent proxy setting on .bashrc
- Put the settings into .bashrc:
$ echo "http_proxy='http://myusername:mypassword@myproxyaddress:myproxyport'" >> .bashrc
- Activate the change:
$ source .bashrc
- Rerun apt-get
Method 6 (without GUI) - permanent settings on apt.conf ~ need sudo
- Append your proxy settings to /etc/apt/apt.conf (choose your proxy, either http, https, ftp, or socks:
$ sudo echo -e 'Acquire::http::proxy "http://myusername:mypassword@myproxyaddress:myproxyport/";\nAcquire::https::proxy "https://myusername:mypassword@myproxyaddress:myproxyport/";\nAcquire::ftp::proxy "ftp://myusername:mypassword@myproxyaddress:myproxyport/";\nAcquire::socks::proxy "socks://myusername:mypassword@myproxyaddress:myproxyport/";' >> /etc/apt/apt.conf
- Rerun apt
You can refer to here, on how to determine your proxy ip address and port using curl.