apt-get behind proxy. Special characters in username and password
Asked Answered
C

2

5

I would like to set apt-get to use a proxy on my ubuntu box. I have successfully configured synaptic to use a proxy, so I can install packages, but I would like to be able to use the command line.

My work proxy requires both a username and password, both of which have special characters in them.

In my .bashrc I have

export http_proxy="http://user@company:P@[email protected]:80/"

however, this doesn't work.

I've also tried escaping the special characters but that doesn't seem to work either:

export http_proxy="http://user\@company:P\@\$\[email protected]:80/"
Containment answered 14/2, 2012 at 18:26 Comment(2)
duplicate of askubuntu.com/questions/60217/… ?Mudlark
I did see that post, however, escaping the special characters doesn't seem to be working.Containment
C
6

Seemed to be a combination of 2 things. I needed to use escape codes for the special characters and I needed to add entries to /etc/apt/apt.conf. (Supposedly, exporting the _proxy environment variables should make apt-get work, but I did not have that luck.)

/etc/apt/apt.conf:

APT::Get::AllowUnauthenticated 1;
Acquire::http::proxy "http://user%40company:P%40%24%[email protected]:80/";
Acquire::ftp::proxy "ftp://user%40company:P%40%24%[email protected]:80/";
Acquire::https::proxy "https://user%40company:P%40%24%[email protected]:80/";

.bashrc:

export http_proxy="http://user%40company:P%40%24%[email protected]:80/";
export ftp_proxy="ftp://user%40company:P%40%24%[email protected]:80/";
export https_proxy="https://user%40company:P%40%24%[email protected]:80/";
Containment answered 29/2, 2012 at 19:26 Comment(2)
URL encoding may be found here: w3schools.com/tags/ref_urlencode.aspHeisel
What if @ is followed by numbers? example ````Pass@40Word```.Pharos
S
1

Even more simple and Reliable!

General Syntax:

sudo {http,https,ftp}_proxy=http://<username>:<password>@<proxy_url/_proxyip>:<port>/

wget --timeout=5 --no-check-certificate http://<website_url>

Example:

[root@localhost ~]# sudo {http,https,ftp}_proxy=http://username:[email protected]:6050/

wget --timeout=5 --no-check-certificate http://google.com

{http,https,ftp}_proxy -> http, https, ftp urls. Seperated by comma.

--timeout=5 -> Connection to keep alive in seconds.

-no-check-certificate -> Ignore SSL / Certificate Verification.

--spider -> If you want to test the connectivity without downloading the file.

Notes:

Online Converter:

Replace special characters with its equivalent hexadecimal unicode. For a list of unicodes refer the website https://unicode-table.com (or) http://unicodelookup.com

Local Converter using Python:

Reference: conversion of password "p@s#w:E" to unicode will be as follows,

@ = %40
$ = %24
# = %23
: = %3A
p@s#w:E = p%40s%23w%3AE

Input:

[root@localhost ~]# python -c "import sys, urllib as enc; print enc.quote_plus(sys.argv[1])" "p@s#w:E"

Output:

p%40s%23w%3AE
Stonewall answered 15/7, 2018 at 13:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.