Wanted to post this more for my edification than anything else, but perhaps someone will make some use of it.
If you need to use apt-get behind a proxy, put this little script in your .bashrc file.
echo "Proxy username: ";
read -e username;
echo "Proxy password: ";
read -es password;
echo "Proxy server: ";
read -e server;
echo "Proxy port: ";
read -e port;
After you save & close your .bashrc file, logout and back in. You can then run proxy from the command line to execute the function and export the http_proxy environment variable.
There are a number of great reasons to use this method versus other ones, such as hardcoding your proxy settings in a file:
- If you have a special character in your password, exporting via command line without escaping it properly will not work. Using the variable method gets around that.
- You don’t have to save your valuable password someplace that someone else with access to that same server could also see it.
- You don’t have to remember the command, or Google for it everytime you forget (like I did!)
Hope this helps!