Configure proxy for APT?
I need to configure proxy. There wasn't apt.conf file in etc/apt/ so I've created it using nano.
But I don't understand what I need to write there. I've written
http_proxy = http://lgn:pwd@192.168.1.254:8080/ there and then restarted networking. But when I try to apt-get update - it doesn't work.
Actually I don't understand what port and ip I should write in apt.conf file(there was example with 192.168.1.254 ip and 8080 port so I decided to use them).
apt
add a comment |
I need to configure proxy. There wasn't apt.conf file in etc/apt/ so I've created it using nano.
But I don't understand what I need to write there. I've written
http_proxy = http://lgn:pwd@192.168.1.254:8080/ there and then restarted networking. But when I try to apt-get update - it doesn't work.
Actually I don't understand what port and ip I should write in apt.conf file(there was example with 192.168.1.254 ip and 8080 port so I decided to use them).
apt
There is a change in proxy settings to get work in corporate proxy in ubuntu visit github.com/navinas33/docker_ubuntu.git it works...
– Navin a.s
Jan 12 '17 at 6:32
add a comment |
I need to configure proxy. There wasn't apt.conf file in etc/apt/ so I've created it using nano.
But I don't understand what I need to write there. I've written
http_proxy = http://lgn:pwd@192.168.1.254:8080/ there and then restarted networking. But when I try to apt-get update - it doesn't work.
Actually I don't understand what port and ip I should write in apt.conf file(there was example with 192.168.1.254 ip and 8080 port so I decided to use them).
apt
I need to configure proxy. There wasn't apt.conf file in etc/apt/ so I've created it using nano.
But I don't understand what I need to write there. I've written
http_proxy = http://lgn:pwd@192.168.1.254:8080/ there and then restarted networking. But when I try to apt-get update - it doesn't work.
Actually I don't understand what port and ip I should write in apt.conf file(there was example with 192.168.1.254 ip and 8080 port so I decided to use them).
apt
apt
edited Apr 11 '13 at 15:19
Jorge Castro
37.1k106422617
37.1k106422617
asked Feb 17 '13 at 12:24
lapotslapots
443156
443156
There is a change in proxy settings to get work in corporate proxy in ubuntu visit github.com/navinas33/docker_ubuntu.git it works...
– Navin a.s
Jan 12 '17 at 6:32
add a comment |
There is a change in proxy settings to get work in corporate proxy in ubuntu visit github.com/navinas33/docker_ubuntu.git it works...
– Navin a.s
Jan 12 '17 at 6:32
There is a change in proxy settings to get work in corporate proxy in ubuntu visit github.com/navinas33/docker_ubuntu.git it works...
– Navin a.s
Jan 12 '17 at 6:32
There is a change in proxy settings to get work in corporate proxy in ubuntu visit github.com/navinas33/docker_ubuntu.git it works...
– Navin a.s
Jan 12 '17 at 6:32
add a comment |
6 Answers
6
active
oldest
votes
To use a proxy, you need a proxy server. The IP and port have to be from this proxy server. Login and pwd must be your user and password on the proxy server (if the proxy requires login).
From help.ubuntu.com site:
APT configuration file method
This method uses the apt.conf file which is found in your /etc/apt/ directory. This method is useful if you only want apt-get (and not other applications) to use a http-proxy permanently.
On some installations there will be no apt-conf file set up. Edit apt-conf file (or create a new one if you have no one yet) using the editor of your choice.
sudo nano /etc/apt/apt.conf
Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).
Acquire::http::Proxy "http://yourproxyaddress:proxyport";
Save the apt.conf file.
If your proxy needs a login/password, substitute:
"http://yourproxyaddress:proxyport";
with:
"http://username:password@yourproxyaddress:proxyport";
using username and password from the proxy server.
6
Adding a separate local file in/etc/apt/apt.conf.d/is preferrable so you don't have to edit the system's basic configuration files. That way, if they are updated in a subsequent package version, you don't have to merge in your local changes by hand.
– tripleee
Jan 27 '17 at 8:06
Is there a proxy conf file on the user directory?
– becko
Feb 15 '17 at 14:32
This answer needs an update: gksudo is obsolete. Consider suggesting other non-GUI editor orsudo -Hinstead of gksudo if using gedit or similar.
– user692175
Nov 16 '17 at 4:45
add a comment |
Something like the following should work:
Acquire::http::proxy "http://lgn:pwd@192.168.1.254:8080/";
Acquire::https::proxy "http://lgn:pwd@192.168.1.254:8080/";
Is there is difference what port and ip to use?
– lapots
Feb 17 '13 at 12:36
Well, yes, you need to put in the correct details for the proxy you want to use of course.
– Dennis Kaarsemaker
Feb 17 '13 at 12:37
er...ip - it is router's ip? I mean this ip I used from example but all router's setting I configure in browser using192.168.1.1ip. I should use .1? and login and password should be ubuntu's root or router's?
– lapots
Feb 17 '13 at 12:40
2
Do you even know what you're doing? How do you know you need to use a proxy if you don't know the details for it?
– Dennis Kaarsemaker
Feb 17 '13 at 12:47
5
Then ask your teacher. This is not a "do my homework for me" site.
– Dennis Kaarsemaker
Feb 17 '13 at 12:51
|
show 1 more comment
This is a more general answer along with apt config.
As there a lot of places to configure proxy settings, it might get confusing at beginning. Let me summarize some things and suggest some good practices.
For console programs
Ex: wget, git and almost every console application which connects to internet.
If you want to configure proxy every time you run your commands for some reason then set the environment variables using following commands.
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export ftp_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
Else if you want to use the same settings everytime for all users, then use of these.
Configure in bashrc
$ nano /etc/bash.bashrc
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export ftp_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
Configure in /etc/environment
$ nano /etc/environment
https_proxy="http://myproxy.server.com:8080/"
ftp_proxy="http://myproxy.server.com:8080/" ...
Configure using GUI
Open the network settings and set the your system wide network proxy.
Network -> Network proxy -> Configure -> Apply system wide.
But this might not be useful if you have authentication for the proxy.
For apt.
You need to do some extra work for apt, as incidentally apt doesn't obey environment variables,
$ nano /etc/apt/apt.conf
Acquire::http::Proxy "http://USERNAME:PASSWORD@SERVER:PORT";
Acquire::https::Proxy "https://USERNAME:PASSWORD@SERVER:PORT";
For everything out of this scope, there must be an option to configure proxy settings in the application itself. If not I'm sorry ;)
2
the config in /etc/environment is very important because if you just setup the http_proxy var for your user, when you go into sudo mode (for stuff like 'sudo apt-get update'), the terminal usually does not preserve the current environment vars ; very important to test your settings : sudo echo $http_proxy
– belun
Jun 28 '17 at 17:51
HTTP_PROXY(in upper case) appears to be the standard name for that variable, though many programs will fall back to the lower case version.https_proxy(note lower case) is the correct capitalisation for that, but you'd never use it alone, as you do in your/etc/environmentabove. (I think thesis a typo.)
– Curt J. Sampson
Sep 6 '18 at 2:08
add a comment |
What you can do is also try to run command with sudo -E, which will take the environment settings. It seems to work for me when I try to update, add-apt-repository, and install.
Example:
sudo -E add-apt-repository ppa:xxxxx
According to @David Foerster this only works for manual interaction using shell, but it won't work on automated tasks and services invoking Apt without user interaction.
That won't help with automated tasks and services invoking Apt without user interaction though.
– David Foerster
Jun 20 '17 at 17:05
Thank you for the notice, I will add your comment to the response.
– Frank Qiu
Jun 20 '17 at 17:53
add a comment |
If you need to use apt behind a proxy, probably everything else also needs the proxy config.
I like to manage my proxy settings in one place, which would be the environment variable.
For that I create a /etc/profiles.d/99-proxy.sh, that contains the necessary proxy settings (like larent described):
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export https_proxy=$http_proxy
export ftps_proxy=$http_proxy
that way, all users on that machine have access to the proxy. (don't forget chmod a+x)
When you use apt or apt-get as a user, that user is able to use sudo.
Like Frank Qiu described, sudo does not pass environment variables.
For that you can add
Defaults env_keep += "http_proxy https_proxy ftp_proxy"
to (e.g.)
/etc/sudoers.d/00-environment
or directly into the
/etc/sudoers
file. That way you only have to manage the proxy settings in one place.
add a comment |
The original question might be in wrong direction. I believe you want to setup a proxy server in Linux ?
Well that is completely different than wanting to use a existing proxy from Linux environment.
If your question is the first one then use any third party services to configure a proxy server in Linux. An example could be squid.
Simple commands to install squid:
$ sudo apt-get install squid3
Then edit the configuration to allow the Local Net (in this case your own machine).
$ sudo vi /etc/squid3/squid.conf
Add/Edit the following lines:
http_access allow local_net
acl local_net src 192.168.1.0/255.255.255.0
Assuming your IP for the Linux machine is in 192.168.1/24 block.
Probably most readers of this question already installed squid ;), also set thehttp[s]_proxyENV variables, and now wonder, why APT still doesn't work. But if you're getting HTTP 403 from everything except the machine withsquid- do look once again for all occurences of the worddenywhich are not commented. (especially withhttp_accesson the same line.
– Tomasz Gandor
Jan 8 at 21:40
add a comment |
protected by Community♦ Sep 25 '18 at 19:29
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
To use a proxy, you need a proxy server. The IP and port have to be from this proxy server. Login and pwd must be your user and password on the proxy server (if the proxy requires login).
From help.ubuntu.com site:
APT configuration file method
This method uses the apt.conf file which is found in your /etc/apt/ directory. This method is useful if you only want apt-get (and not other applications) to use a http-proxy permanently.
On some installations there will be no apt-conf file set up. Edit apt-conf file (or create a new one if you have no one yet) using the editor of your choice.
sudo nano /etc/apt/apt.conf
Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).
Acquire::http::Proxy "http://yourproxyaddress:proxyport";
Save the apt.conf file.
If your proxy needs a login/password, substitute:
"http://yourproxyaddress:proxyport";
with:
"http://username:password@yourproxyaddress:proxyport";
using username and password from the proxy server.
6
Adding a separate local file in/etc/apt/apt.conf.d/is preferrable so you don't have to edit the system's basic configuration files. That way, if they are updated in a subsequent package version, you don't have to merge in your local changes by hand.
– tripleee
Jan 27 '17 at 8:06
Is there a proxy conf file on the user directory?
– becko
Feb 15 '17 at 14:32
This answer needs an update: gksudo is obsolete. Consider suggesting other non-GUI editor orsudo -Hinstead of gksudo if using gedit or similar.
– user692175
Nov 16 '17 at 4:45
add a comment |
To use a proxy, you need a proxy server. The IP and port have to be from this proxy server. Login and pwd must be your user and password on the proxy server (if the proxy requires login).
From help.ubuntu.com site:
APT configuration file method
This method uses the apt.conf file which is found in your /etc/apt/ directory. This method is useful if you only want apt-get (and not other applications) to use a http-proxy permanently.
On some installations there will be no apt-conf file set up. Edit apt-conf file (or create a new one if you have no one yet) using the editor of your choice.
sudo nano /etc/apt/apt.conf
Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).
Acquire::http::Proxy "http://yourproxyaddress:proxyport";
Save the apt.conf file.
If your proxy needs a login/password, substitute:
"http://yourproxyaddress:proxyport";
with:
"http://username:password@yourproxyaddress:proxyport";
using username and password from the proxy server.
6
Adding a separate local file in/etc/apt/apt.conf.d/is preferrable so you don't have to edit the system's basic configuration files. That way, if they are updated in a subsequent package version, you don't have to merge in your local changes by hand.
– tripleee
Jan 27 '17 at 8:06
Is there a proxy conf file on the user directory?
– becko
Feb 15 '17 at 14:32
This answer needs an update: gksudo is obsolete. Consider suggesting other non-GUI editor orsudo -Hinstead of gksudo if using gedit or similar.
– user692175
Nov 16 '17 at 4:45
add a comment |
To use a proxy, you need a proxy server. The IP and port have to be from this proxy server. Login and pwd must be your user and password on the proxy server (if the proxy requires login).
From help.ubuntu.com site:
APT configuration file method
This method uses the apt.conf file which is found in your /etc/apt/ directory. This method is useful if you only want apt-get (and not other applications) to use a http-proxy permanently.
On some installations there will be no apt-conf file set up. Edit apt-conf file (or create a new one if you have no one yet) using the editor of your choice.
sudo nano /etc/apt/apt.conf
Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).
Acquire::http::Proxy "http://yourproxyaddress:proxyport";
Save the apt.conf file.
If your proxy needs a login/password, substitute:
"http://yourproxyaddress:proxyport";
with:
"http://username:password@yourproxyaddress:proxyport";
using username and password from the proxy server.
To use a proxy, you need a proxy server. The IP and port have to be from this proxy server. Login and pwd must be your user and password on the proxy server (if the proxy requires login).
From help.ubuntu.com site:
APT configuration file method
This method uses the apt.conf file which is found in your /etc/apt/ directory. This method is useful if you only want apt-get (and not other applications) to use a http-proxy permanently.
On some installations there will be no apt-conf file set up. Edit apt-conf file (or create a new one if you have no one yet) using the editor of your choice.
sudo nano /etc/apt/apt.conf
Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).
Acquire::http::Proxy "http://yourproxyaddress:proxyport";
Save the apt.conf file.
If your proxy needs a login/password, substitute:
"http://yourproxyaddress:proxyport";
with:
"http://username:password@yourproxyaddress:proxyport";
using username and password from the proxy server.
edited Dec 9 '17 at 15:15
answered Feb 17 '13 at 13:08
laurentlaurent
5,3091923
5,3091923
6
Adding a separate local file in/etc/apt/apt.conf.d/is preferrable so you don't have to edit the system's basic configuration files. That way, if they are updated in a subsequent package version, you don't have to merge in your local changes by hand.
– tripleee
Jan 27 '17 at 8:06
Is there a proxy conf file on the user directory?
– becko
Feb 15 '17 at 14:32
This answer needs an update: gksudo is obsolete. Consider suggesting other non-GUI editor orsudo -Hinstead of gksudo if using gedit or similar.
– user692175
Nov 16 '17 at 4:45
add a comment |
6
Adding a separate local file in/etc/apt/apt.conf.d/is preferrable so you don't have to edit the system's basic configuration files. That way, if they are updated in a subsequent package version, you don't have to merge in your local changes by hand.
– tripleee
Jan 27 '17 at 8:06
Is there a proxy conf file on the user directory?
– becko
Feb 15 '17 at 14:32
This answer needs an update: gksudo is obsolete. Consider suggesting other non-GUI editor orsudo -Hinstead of gksudo if using gedit or similar.
– user692175
Nov 16 '17 at 4:45
6
6
Adding a separate local file in
/etc/apt/apt.conf.d/ is preferrable so you don't have to edit the system's basic configuration files. That way, if they are updated in a subsequent package version, you don't have to merge in your local changes by hand.– tripleee
Jan 27 '17 at 8:06
Adding a separate local file in
/etc/apt/apt.conf.d/ is preferrable so you don't have to edit the system's basic configuration files. That way, if they are updated in a subsequent package version, you don't have to merge in your local changes by hand.– tripleee
Jan 27 '17 at 8:06
Is there a proxy conf file on the user directory?
– becko
Feb 15 '17 at 14:32
Is there a proxy conf file on the user directory?
– becko
Feb 15 '17 at 14:32
This answer needs an update: gksudo is obsolete. Consider suggesting other non-GUI editor or
sudo -H instead of gksudo if using gedit or similar.– user692175
Nov 16 '17 at 4:45
This answer needs an update: gksudo is obsolete. Consider suggesting other non-GUI editor or
sudo -H instead of gksudo if using gedit or similar.– user692175
Nov 16 '17 at 4:45
add a comment |
Something like the following should work:
Acquire::http::proxy "http://lgn:pwd@192.168.1.254:8080/";
Acquire::https::proxy "http://lgn:pwd@192.168.1.254:8080/";
Is there is difference what port and ip to use?
– lapots
Feb 17 '13 at 12:36
Well, yes, you need to put in the correct details for the proxy you want to use of course.
– Dennis Kaarsemaker
Feb 17 '13 at 12:37
er...ip - it is router's ip? I mean this ip I used from example but all router's setting I configure in browser using192.168.1.1ip. I should use .1? and login and password should be ubuntu's root or router's?
– lapots
Feb 17 '13 at 12:40
2
Do you even know what you're doing? How do you know you need to use a proxy if you don't know the details for it?
– Dennis Kaarsemaker
Feb 17 '13 at 12:47
5
Then ask your teacher. This is not a "do my homework for me" site.
– Dennis Kaarsemaker
Feb 17 '13 at 12:51
|
show 1 more comment
Something like the following should work:
Acquire::http::proxy "http://lgn:pwd@192.168.1.254:8080/";
Acquire::https::proxy "http://lgn:pwd@192.168.1.254:8080/";
Is there is difference what port and ip to use?
– lapots
Feb 17 '13 at 12:36
Well, yes, you need to put in the correct details for the proxy you want to use of course.
– Dennis Kaarsemaker
Feb 17 '13 at 12:37
er...ip - it is router's ip? I mean this ip I used from example but all router's setting I configure in browser using192.168.1.1ip. I should use .1? and login and password should be ubuntu's root or router's?
– lapots
Feb 17 '13 at 12:40
2
Do you even know what you're doing? How do you know you need to use a proxy if you don't know the details for it?
– Dennis Kaarsemaker
Feb 17 '13 at 12:47
5
Then ask your teacher. This is not a "do my homework for me" site.
– Dennis Kaarsemaker
Feb 17 '13 at 12:51
|
show 1 more comment
Something like the following should work:
Acquire::http::proxy "http://lgn:pwd@192.168.1.254:8080/";
Acquire::https::proxy "http://lgn:pwd@192.168.1.254:8080/";
Something like the following should work:
Acquire::http::proxy "http://lgn:pwd@192.168.1.254:8080/";
Acquire::https::proxy "http://lgn:pwd@192.168.1.254:8080/";
answered Feb 17 '13 at 12:31
Dennis KaarsemakerDennis Kaarsemaker
5,8521736
5,8521736
Is there is difference what port and ip to use?
– lapots
Feb 17 '13 at 12:36
Well, yes, you need to put in the correct details for the proxy you want to use of course.
– Dennis Kaarsemaker
Feb 17 '13 at 12:37
er...ip - it is router's ip? I mean this ip I used from example but all router's setting I configure in browser using192.168.1.1ip. I should use .1? and login and password should be ubuntu's root or router's?
– lapots
Feb 17 '13 at 12:40
2
Do you even know what you're doing? How do you know you need to use a proxy if you don't know the details for it?
– Dennis Kaarsemaker
Feb 17 '13 at 12:47
5
Then ask your teacher. This is not a "do my homework for me" site.
– Dennis Kaarsemaker
Feb 17 '13 at 12:51
|
show 1 more comment
Is there is difference what port and ip to use?
– lapots
Feb 17 '13 at 12:36
Well, yes, you need to put in the correct details for the proxy you want to use of course.
– Dennis Kaarsemaker
Feb 17 '13 at 12:37
er...ip - it is router's ip? I mean this ip I used from example but all router's setting I configure in browser using192.168.1.1ip. I should use .1? and login and password should be ubuntu's root or router's?
– lapots
Feb 17 '13 at 12:40
2
Do you even know what you're doing? How do you know you need to use a proxy if you don't know the details for it?
– Dennis Kaarsemaker
Feb 17 '13 at 12:47
5
Then ask your teacher. This is not a "do my homework for me" site.
– Dennis Kaarsemaker
Feb 17 '13 at 12:51
Is there is difference what port and ip to use?
– lapots
Feb 17 '13 at 12:36
Is there is difference what port and ip to use?
– lapots
Feb 17 '13 at 12:36
Well, yes, you need to put in the correct details for the proxy you want to use of course.
– Dennis Kaarsemaker
Feb 17 '13 at 12:37
Well, yes, you need to put in the correct details for the proxy you want to use of course.
– Dennis Kaarsemaker
Feb 17 '13 at 12:37
er...ip - it is router's ip? I mean this ip I used from example but all router's setting I configure in browser using
192.168.1.1 ip. I should use .1? and login and password should be ubuntu's root or router's?– lapots
Feb 17 '13 at 12:40
er...ip - it is router's ip? I mean this ip I used from example but all router's setting I configure in browser using
192.168.1.1 ip. I should use .1? and login and password should be ubuntu's root or router's?– lapots
Feb 17 '13 at 12:40
2
2
Do you even know what you're doing? How do you know you need to use a proxy if you don't know the details for it?
– Dennis Kaarsemaker
Feb 17 '13 at 12:47
Do you even know what you're doing? How do you know you need to use a proxy if you don't know the details for it?
– Dennis Kaarsemaker
Feb 17 '13 at 12:47
5
5
Then ask your teacher. This is not a "do my homework for me" site.
– Dennis Kaarsemaker
Feb 17 '13 at 12:51
Then ask your teacher. This is not a "do my homework for me" site.
– Dennis Kaarsemaker
Feb 17 '13 at 12:51
|
show 1 more comment
This is a more general answer along with apt config.
As there a lot of places to configure proxy settings, it might get confusing at beginning. Let me summarize some things and suggest some good practices.
For console programs
Ex: wget, git and almost every console application which connects to internet.
If you want to configure proxy every time you run your commands for some reason then set the environment variables using following commands.
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export ftp_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
Else if you want to use the same settings everytime for all users, then use of these.
Configure in bashrc
$ nano /etc/bash.bashrc
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export ftp_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
Configure in /etc/environment
$ nano /etc/environment
https_proxy="http://myproxy.server.com:8080/"
ftp_proxy="http://myproxy.server.com:8080/" ...
Configure using GUI
Open the network settings and set the your system wide network proxy.
Network -> Network proxy -> Configure -> Apply system wide.
But this might not be useful if you have authentication for the proxy.
For apt.
You need to do some extra work for apt, as incidentally apt doesn't obey environment variables,
$ nano /etc/apt/apt.conf
Acquire::http::Proxy "http://USERNAME:PASSWORD@SERVER:PORT";
Acquire::https::Proxy "https://USERNAME:PASSWORD@SERVER:PORT";
For everything out of this scope, there must be an option to configure proxy settings in the application itself. If not I'm sorry ;)
2
the config in /etc/environment is very important because if you just setup the http_proxy var for your user, when you go into sudo mode (for stuff like 'sudo apt-get update'), the terminal usually does not preserve the current environment vars ; very important to test your settings : sudo echo $http_proxy
– belun
Jun 28 '17 at 17:51
HTTP_PROXY(in upper case) appears to be the standard name for that variable, though many programs will fall back to the lower case version.https_proxy(note lower case) is the correct capitalisation for that, but you'd never use it alone, as you do in your/etc/environmentabove. (I think thesis a typo.)
– Curt J. Sampson
Sep 6 '18 at 2:08
add a comment |
This is a more general answer along with apt config.
As there a lot of places to configure proxy settings, it might get confusing at beginning. Let me summarize some things and suggest some good practices.
For console programs
Ex: wget, git and almost every console application which connects to internet.
If you want to configure proxy every time you run your commands for some reason then set the environment variables using following commands.
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export ftp_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
Else if you want to use the same settings everytime for all users, then use of these.
Configure in bashrc
$ nano /etc/bash.bashrc
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export ftp_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
Configure in /etc/environment
$ nano /etc/environment
https_proxy="http://myproxy.server.com:8080/"
ftp_proxy="http://myproxy.server.com:8080/" ...
Configure using GUI
Open the network settings and set the your system wide network proxy.
Network -> Network proxy -> Configure -> Apply system wide.
But this might not be useful if you have authentication for the proxy.
For apt.
You need to do some extra work for apt, as incidentally apt doesn't obey environment variables,
$ nano /etc/apt/apt.conf
Acquire::http::Proxy "http://USERNAME:PASSWORD@SERVER:PORT";
Acquire::https::Proxy "https://USERNAME:PASSWORD@SERVER:PORT";
For everything out of this scope, there must be an option to configure proxy settings in the application itself. If not I'm sorry ;)
2
the config in /etc/environment is very important because if you just setup the http_proxy var for your user, when you go into sudo mode (for stuff like 'sudo apt-get update'), the terminal usually does not preserve the current environment vars ; very important to test your settings : sudo echo $http_proxy
– belun
Jun 28 '17 at 17:51
HTTP_PROXY(in upper case) appears to be the standard name for that variable, though many programs will fall back to the lower case version.https_proxy(note lower case) is the correct capitalisation for that, but you'd never use it alone, as you do in your/etc/environmentabove. (I think thesis a typo.)
– Curt J. Sampson
Sep 6 '18 at 2:08
add a comment |
This is a more general answer along with apt config.
As there a lot of places to configure proxy settings, it might get confusing at beginning. Let me summarize some things and suggest some good practices.
For console programs
Ex: wget, git and almost every console application which connects to internet.
If you want to configure proxy every time you run your commands for some reason then set the environment variables using following commands.
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export ftp_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
Else if you want to use the same settings everytime for all users, then use of these.
Configure in bashrc
$ nano /etc/bash.bashrc
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export ftp_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
Configure in /etc/environment
$ nano /etc/environment
https_proxy="http://myproxy.server.com:8080/"
ftp_proxy="http://myproxy.server.com:8080/" ...
Configure using GUI
Open the network settings and set the your system wide network proxy.
Network -> Network proxy -> Configure -> Apply system wide.
But this might not be useful if you have authentication for the proxy.
For apt.
You need to do some extra work for apt, as incidentally apt doesn't obey environment variables,
$ nano /etc/apt/apt.conf
Acquire::http::Proxy "http://USERNAME:PASSWORD@SERVER:PORT";
Acquire::https::Proxy "https://USERNAME:PASSWORD@SERVER:PORT";
For everything out of this scope, there must be an option to configure proxy settings in the application itself. If not I'm sorry ;)
This is a more general answer along with apt config.
As there a lot of places to configure proxy settings, it might get confusing at beginning. Let me summarize some things and suggest some good practices.
For console programs
Ex: wget, git and almost every console application which connects to internet.
If you want to configure proxy every time you run your commands for some reason then set the environment variables using following commands.
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export ftp_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
Else if you want to use the same settings everytime for all users, then use of these.
Configure in bashrc
$ nano /etc/bash.bashrc
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export ftp_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
Configure in /etc/environment
$ nano /etc/environment
https_proxy="http://myproxy.server.com:8080/"
ftp_proxy="http://myproxy.server.com:8080/" ...
Configure using GUI
Open the network settings and set the your system wide network proxy.
Network -> Network proxy -> Configure -> Apply system wide.
But this might not be useful if you have authentication for the proxy.
For apt.
You need to do some extra work for apt, as incidentally apt doesn't obey environment variables,
$ nano /etc/apt/apt.conf
Acquire::http::Proxy "http://USERNAME:PASSWORD@SERVER:PORT";
Acquire::https::Proxy "https://USERNAME:PASSWORD@SERVER:PORT";
For everything out of this scope, there must be an option to configure proxy settings in the application itself. If not I'm sorry ;)
answered May 30 '17 at 3:50
matrixisrealmatrixisreal
44638
44638
2
the config in /etc/environment is very important because if you just setup the http_proxy var for your user, when you go into sudo mode (for stuff like 'sudo apt-get update'), the terminal usually does not preserve the current environment vars ; very important to test your settings : sudo echo $http_proxy
– belun
Jun 28 '17 at 17:51
HTTP_PROXY(in upper case) appears to be the standard name for that variable, though many programs will fall back to the lower case version.https_proxy(note lower case) is the correct capitalisation for that, but you'd never use it alone, as you do in your/etc/environmentabove. (I think thesis a typo.)
– Curt J. Sampson
Sep 6 '18 at 2:08
add a comment |
2
the config in /etc/environment is very important because if you just setup the http_proxy var for your user, when you go into sudo mode (for stuff like 'sudo apt-get update'), the terminal usually does not preserve the current environment vars ; very important to test your settings : sudo echo $http_proxy
– belun
Jun 28 '17 at 17:51
HTTP_PROXY(in upper case) appears to be the standard name for that variable, though many programs will fall back to the lower case version.https_proxy(note lower case) is the correct capitalisation for that, but you'd never use it alone, as you do in your/etc/environmentabove. (I think thesis a typo.)
– Curt J. Sampson
Sep 6 '18 at 2:08
2
2
the config in /etc/environment is very important because if you just setup the http_proxy var for your user, when you go into sudo mode (for stuff like 'sudo apt-get update'), the terminal usually does not preserve the current environment vars ; very important to test your settings : sudo echo $http_proxy
– belun
Jun 28 '17 at 17:51
the config in /etc/environment is very important because if you just setup the http_proxy var for your user, when you go into sudo mode (for stuff like 'sudo apt-get update'), the terminal usually does not preserve the current environment vars ; very important to test your settings : sudo echo $http_proxy
– belun
Jun 28 '17 at 17:51
HTTP_PROXY (in upper case) appears to be the standard name for that variable, though many programs will fall back to the lower case version. https_proxy (note lower case) is the correct capitalisation for that, but you'd never use it alone, as you do in your /etc/environment above. (I think the s is a typo.)– Curt J. Sampson
Sep 6 '18 at 2:08
HTTP_PROXY (in upper case) appears to be the standard name for that variable, though many programs will fall back to the lower case version. https_proxy (note lower case) is the correct capitalisation for that, but you'd never use it alone, as you do in your /etc/environment above. (I think the s is a typo.)– Curt J. Sampson
Sep 6 '18 at 2:08
add a comment |
What you can do is also try to run command with sudo -E, which will take the environment settings. It seems to work for me when I try to update, add-apt-repository, and install.
Example:
sudo -E add-apt-repository ppa:xxxxx
According to @David Foerster this only works for manual interaction using shell, but it won't work on automated tasks and services invoking Apt without user interaction.
That won't help with automated tasks and services invoking Apt without user interaction though.
– David Foerster
Jun 20 '17 at 17:05
Thank you for the notice, I will add your comment to the response.
– Frank Qiu
Jun 20 '17 at 17:53
add a comment |
What you can do is also try to run command with sudo -E, which will take the environment settings. It seems to work for me when I try to update, add-apt-repository, and install.
Example:
sudo -E add-apt-repository ppa:xxxxx
According to @David Foerster this only works for manual interaction using shell, but it won't work on automated tasks and services invoking Apt without user interaction.
That won't help with automated tasks and services invoking Apt without user interaction though.
– David Foerster
Jun 20 '17 at 17:05
Thank you for the notice, I will add your comment to the response.
– Frank Qiu
Jun 20 '17 at 17:53
add a comment |
What you can do is also try to run command with sudo -E, which will take the environment settings. It seems to work for me when I try to update, add-apt-repository, and install.
Example:
sudo -E add-apt-repository ppa:xxxxx
According to @David Foerster this only works for manual interaction using shell, but it won't work on automated tasks and services invoking Apt without user interaction.
What you can do is also try to run command with sudo -E, which will take the environment settings. It seems to work for me when I try to update, add-apt-repository, and install.
Example:
sudo -E add-apt-repository ppa:xxxxx
According to @David Foerster this only works for manual interaction using shell, but it won't work on automated tasks and services invoking Apt without user interaction.
edited Jun 20 '17 at 17:56
answered Jun 20 '17 at 16:32
Frank QiuFrank Qiu
412
412
That won't help with automated tasks and services invoking Apt without user interaction though.
– David Foerster
Jun 20 '17 at 17:05
Thank you for the notice, I will add your comment to the response.
– Frank Qiu
Jun 20 '17 at 17:53
add a comment |
That won't help with automated tasks and services invoking Apt without user interaction though.
– David Foerster
Jun 20 '17 at 17:05
Thank you for the notice, I will add your comment to the response.
– Frank Qiu
Jun 20 '17 at 17:53
That won't help with automated tasks and services invoking Apt without user interaction though.
– David Foerster
Jun 20 '17 at 17:05
That won't help with automated tasks and services invoking Apt without user interaction though.
– David Foerster
Jun 20 '17 at 17:05
Thank you for the notice, I will add your comment to the response.
– Frank Qiu
Jun 20 '17 at 17:53
Thank you for the notice, I will add your comment to the response.
– Frank Qiu
Jun 20 '17 at 17:53
add a comment |
If you need to use apt behind a proxy, probably everything else also needs the proxy config.
I like to manage my proxy settings in one place, which would be the environment variable.
For that I create a /etc/profiles.d/99-proxy.sh, that contains the necessary proxy settings (like larent described):
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export https_proxy=$http_proxy
export ftps_proxy=$http_proxy
that way, all users on that machine have access to the proxy. (don't forget chmod a+x)
When you use apt or apt-get as a user, that user is able to use sudo.
Like Frank Qiu described, sudo does not pass environment variables.
For that you can add
Defaults env_keep += "http_proxy https_proxy ftp_proxy"
to (e.g.)
/etc/sudoers.d/00-environment
or directly into the
/etc/sudoers
file. That way you only have to manage the proxy settings in one place.
add a comment |
If you need to use apt behind a proxy, probably everything else also needs the proxy config.
I like to manage my proxy settings in one place, which would be the environment variable.
For that I create a /etc/profiles.d/99-proxy.sh, that contains the necessary proxy settings (like larent described):
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export https_proxy=$http_proxy
export ftps_proxy=$http_proxy
that way, all users on that machine have access to the proxy. (don't forget chmod a+x)
When you use apt or apt-get as a user, that user is able to use sudo.
Like Frank Qiu described, sudo does not pass environment variables.
For that you can add
Defaults env_keep += "http_proxy https_proxy ftp_proxy"
to (e.g.)
/etc/sudoers.d/00-environment
or directly into the
/etc/sudoers
file. That way you only have to manage the proxy settings in one place.
add a comment |
If you need to use apt behind a proxy, probably everything else also needs the proxy config.
I like to manage my proxy settings in one place, which would be the environment variable.
For that I create a /etc/profiles.d/99-proxy.sh, that contains the necessary proxy settings (like larent described):
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export https_proxy=$http_proxy
export ftps_proxy=$http_proxy
that way, all users on that machine have access to the proxy. (don't forget chmod a+x)
When you use apt or apt-get as a user, that user is able to use sudo.
Like Frank Qiu described, sudo does not pass environment variables.
For that you can add
Defaults env_keep += "http_proxy https_proxy ftp_proxy"
to (e.g.)
/etc/sudoers.d/00-environment
or directly into the
/etc/sudoers
file. That way you only have to manage the proxy settings in one place.
If you need to use apt behind a proxy, probably everything else also needs the proxy config.
I like to manage my proxy settings in one place, which would be the environment variable.
For that I create a /etc/profiles.d/99-proxy.sh, that contains the necessary proxy settings (like larent described):
export http_proxy=http://DOMAINUSERNAME:PASSWORD@SERVER:PORT/
export https_proxy=$http_proxy
export ftps_proxy=$http_proxy
that way, all users on that machine have access to the proxy. (don't forget chmod a+x)
When you use apt or apt-get as a user, that user is able to use sudo.
Like Frank Qiu described, sudo does not pass environment variables.
For that you can add
Defaults env_keep += "http_proxy https_proxy ftp_proxy"
to (e.g.)
/etc/sudoers.d/00-environment
or directly into the
/etc/sudoers
file. That way you only have to manage the proxy settings in one place.
edited Sep 20 '18 at 9:30
abu_bua
4,08181530
4,08181530
answered Sep 20 '18 at 9:14
muluman88muluman88
111
111
add a comment |
add a comment |
The original question might be in wrong direction. I believe you want to setup a proxy server in Linux ?
Well that is completely different than wanting to use a existing proxy from Linux environment.
If your question is the first one then use any third party services to configure a proxy server in Linux. An example could be squid.
Simple commands to install squid:
$ sudo apt-get install squid3
Then edit the configuration to allow the Local Net (in this case your own machine).
$ sudo vi /etc/squid3/squid.conf
Add/Edit the following lines:
http_access allow local_net
acl local_net src 192.168.1.0/255.255.255.0
Assuming your IP for the Linux machine is in 192.168.1/24 block.
Probably most readers of this question already installed squid ;), also set thehttp[s]_proxyENV variables, and now wonder, why APT still doesn't work. But if you're getting HTTP 403 from everything except the machine withsquid- do look once again for all occurences of the worddenywhich are not commented. (especially withhttp_accesson the same line.
– Tomasz Gandor
Jan 8 at 21:40
add a comment |
The original question might be in wrong direction. I believe you want to setup a proxy server in Linux ?
Well that is completely different than wanting to use a existing proxy from Linux environment.
If your question is the first one then use any third party services to configure a proxy server in Linux. An example could be squid.
Simple commands to install squid:
$ sudo apt-get install squid3
Then edit the configuration to allow the Local Net (in this case your own machine).
$ sudo vi /etc/squid3/squid.conf
Add/Edit the following lines:
http_access allow local_net
acl local_net src 192.168.1.0/255.255.255.0
Assuming your IP for the Linux machine is in 192.168.1/24 block.
Probably most readers of this question already installed squid ;), also set thehttp[s]_proxyENV variables, and now wonder, why APT still doesn't work. But if you're getting HTTP 403 from everything except the machine withsquid- do look once again for all occurences of the worddenywhich are not commented. (especially withhttp_accesson the same line.
– Tomasz Gandor
Jan 8 at 21:40
add a comment |
The original question might be in wrong direction. I believe you want to setup a proxy server in Linux ?
Well that is completely different than wanting to use a existing proxy from Linux environment.
If your question is the first one then use any third party services to configure a proxy server in Linux. An example could be squid.
Simple commands to install squid:
$ sudo apt-get install squid3
Then edit the configuration to allow the Local Net (in this case your own machine).
$ sudo vi /etc/squid3/squid.conf
Add/Edit the following lines:
http_access allow local_net
acl local_net src 192.168.1.0/255.255.255.0
Assuming your IP for the Linux machine is in 192.168.1/24 block.
The original question might be in wrong direction. I believe you want to setup a proxy server in Linux ?
Well that is completely different than wanting to use a existing proxy from Linux environment.
If your question is the first one then use any third party services to configure a proxy server in Linux. An example could be squid.
Simple commands to install squid:
$ sudo apt-get install squid3
Then edit the configuration to allow the Local Net (in this case your own machine).
$ sudo vi /etc/squid3/squid.conf
Add/Edit the following lines:
http_access allow local_net
acl local_net src 192.168.1.0/255.255.255.0
Assuming your IP for the Linux machine is in 192.168.1/24 block.
edited Jun 2 '16 at 4:15
Videonauth
24.7k1273102
24.7k1273102
answered Jun 2 '16 at 3:51
NeoNeo
171
171
Probably most readers of this question already installed squid ;), also set thehttp[s]_proxyENV variables, and now wonder, why APT still doesn't work. But if you're getting HTTP 403 from everything except the machine withsquid- do look once again for all occurences of the worddenywhich are not commented. (especially withhttp_accesson the same line.
– Tomasz Gandor
Jan 8 at 21:40
add a comment |
Probably most readers of this question already installed squid ;), also set thehttp[s]_proxyENV variables, and now wonder, why APT still doesn't work. But if you're getting HTTP 403 from everything except the machine withsquid- do look once again for all occurences of the worddenywhich are not commented. (especially withhttp_accesson the same line.
– Tomasz Gandor
Jan 8 at 21:40
Probably most readers of this question already installed squid ;), also set the
http[s]_proxy ENV variables, and now wonder, why APT still doesn't work. But if you're getting HTTP 403 from everything except the machine with squid - do look once again for all occurences of the word deny which are not commented. (especially with http_access on the same line.– Tomasz Gandor
Jan 8 at 21:40
Probably most readers of this question already installed squid ;), also set the
http[s]_proxy ENV variables, and now wonder, why APT still doesn't work. But if you're getting HTTP 403 from everything except the machine with squid - do look once again for all occurences of the word deny which are not commented. (especially with http_access on the same line.– Tomasz Gandor
Jan 8 at 21:40
add a comment |
protected by Community♦ Sep 25 '18 at 19:29
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
There is a change in proxy settings to get work in corporate proxy in ubuntu visit github.com/navinas33/docker_ubuntu.git it works...
– Navin a.s
Jan 12 '17 at 6:32