How about not doing shell hacks, and cofiguring apt directly? echo 'Acquire::http::Proxy "http://me@insecure@box:3128/";' > /etc/apt/apt.conf.d/01proxy I may be off on the syntax; I purged proxy usage on my boxes a while back, so, working from memory.