Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to add the ppa repository (as a root) with the following command:

export HTTP_PROXY="http://firstname.surname@xxx.com:my_pass@165.x.x.232:8080"
add-apt-repository ppa:nilarimogard/webupd8


Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 125, in <module>
    ppa_info = get_ppa_info_from_lp(user, ppa_name)
  File "/usr/lib/python2.7/dist-packages/softwareproperties/ppa.py", line 84, in get_ppa_info_from_lp
    curl.perform()
pycurl.error: (56, 'Received HTTP code 407 from proxy after CONNECT')

Unfortunately it doesn't work. Looks like curl is connecting to the proxy, but the proxy says that Authentication is Required. I've tried with .curlrc, http_proxy env instead, but it doesn't work.

strace -e network,write -s1000 add-apt-repository ppa:nilarimogard/webupd8
socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = 4
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(8080), sin_addr=inet_addr("165.x.x.232")}, 16) = -1 EINPROGRESS (Operation now in progress)
getsockopt(4, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
getpeername(4, {sa_family=AF_INET, sin_port=htons(8080), sin_addr=inet_addr("165.x.x.232")}, [16]) = 0
getsockname(4, {sa_family=AF_INET, sin_port=htons(46025), sin_addr=inet_addr("161.20.75.220")}, [16]) = 0
sendto(4, "CONNECT launchpad.net:443 HTTP/1.1\r\nHost: launchpad.net:443\r\nUser-Agent: PycURL/7.22.0\r\nProxy-Connection: Keep-Alive\r\nAccept: application/json\r\n\r\n", 146, MSG_NOSIGNAL, NULL, 0) = 146
recvfrom(4, "HTTP/1.1 407 Proxy Authentication Required\r\nProxy-Authenticate: BASIC realm=\"proxy\"\r\nCache-Control: no-cache\r\nPragma: no-cache\r\nContent-Type: text/html; charset=utf-8\r\nProxy-Connection: close\r\nSet-Cookie: BCSI-CS-91b9906520151dad=2; Path=/\r\nConnection: close\

Maybe it's because there is @ sign in the username? Wget works with proxy fine.

Related: How do I add a repository from behind a proxy?

Environment

Ubuntu 12.04

curl 7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3

curl Features: GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP

UPDATE

When added credentials into .curlrc

cat ~/.curlrc 
proxy = 165.x.x.232:8080
proxy-user = name.surname@xxx.com:mypass0

It seems to work for the plain curl.

curl www.google.com | head

* Proxy auth using Basic with user 'name.surname@xxx.com'
GET HTTP://www.google.com HTTP/1.1
Proxy-Authorization: Basic cmFmYWwud2llY3pvcmVrQHVi...3R0RDA=
HTTP/1.1 302 Found

Also HTTPS:

curl -v https://www.google.com | head
* Establish HTTP proxy tunnel to www.google.com:443
* Proxy auth using Basic with user 'name.surname@xxx.com'
> CONNECT www.google.com:443 HTTP/1.1
> Host: www.google.com:443
> Proxy-Authorization: Basic cmFmYWwud2llY3pvcmVrQHVi...3R0RDA=
    > User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1     zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Proxy-Connection: Keep-Alive
< HTTP/1.1 200 Connection established
* Proxy replied OK to CONNECT request
* successfully set certificate verify locations

But still doesn't work when adding ppa certificate.

pycurl.error: (56, 'Received HTTP code 407 from proxy after CONNECT')

CURL HEADERS

Headers sent:

CONNECT launchpad.net:443 HTTP/1.1
Host: launchpad.net:443
Proxy-Authorization: Basic cGVvcGxlcmVhbGx5c2hvdWxkQHNhbml0aXplcG9zdHM=
User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
Proxy-Connection: Keep-Alive

Reply:

HTTP/1.1 200 Connection established

PyCURL HEADERS

Headers sent:

CONNECT launchpad.net:443 HTTP/1.1
Host: launchpad.net:443
User-Agent: PycURL/7.22.0
Proxy-Connection: Keep-Alive
Accept: application/json

Reply:

HTTP/1.1 407 Proxy Authentication Required
Proxy-Authenticate: BASIC realm="proxy"

It seems that PyCURL doesn't re-send any Authorization when requested.

share|improve this question
    
Thanks, I've tried but this doesn't help. To make sure that this is not the case, I've included my credentials in .curlrc (without escaping @ seems to work for standard curl command), but not for pycurl. See the updated section. –  kenorb Nov 5 '12 at 13:22
    
Thanks, I thought I missed something. I've reported the bug here: bugs.launchpad.net/ubuntu/+source/apt/+bug/1075180 –  kenorb Nov 5 '12 at 15:00
    
Have you also set https_proxy? See bug bugs.launchpad.net/ubuntu/+source/software-properties/+bug/… –  popey Dec 29 '12 at 19:08
    
Maybe it is a problem related to sessions and environment vars. You could try to export http_proxy and https_proxy in /etc/profile, then reboot the machine (if possible) and try it again. –  jap1968 Dec 30 '12 at 21:50
    
Related to what jap1968 is saying above me, I'd made sure that both http_proxy and HTTP_PROXY are set (and https_proxy and HTTPS_PROXY). Thanks to Linux's case-sensitivity, those are actually two different variables - and, best of all, not all programs will use one or the other. Granted, it sounds more like an issue with how the username/password combination is being sent (because of '@'), but it's worth a shot anyway. –  YellowApple Jan 22 '13 at 20:08
add comment

2 Answers 2

up vote 4 down vote accepted

Workaround if apt-get still works behind the proxy

  • add sources manually to /etc/apt/sources.list
  • add gpg key

Adding sources manually

I think on launchpad.net every ppa still contains a small description how to add sources manually. The launchpad site for your mentioned ppa ppa:nilarimogard/webupd8 is https://launchpad.net/~nilarimogard/+archive/webupd8. If you scroll down you see an expandable label Technical details about this PPA. If you expand it you find the description how to add sources manually. Add the following lines to mentioned /etc/apt/sources.list

deb http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu quantal main 
deb-src http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu quantal main 

Of course you have to adjust quantal to whatever version you are currently using.

Adding the Signing Key

The description also contains a signing key. This is important, so that your system can always verify that you actually access a trustworthy ppa-address. In case of your ppa that is 1024R/4C9D234C(can also be found under Technical details about this PPA), where the number behind the slash is important. You can add the fingerprint via the apt-key program. Typically you would perform the following command

 sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 4C9D234C

Adding if apt-key doesn't work through proxy

Since you already had problems with the add-apt-repository program this might not work either. So instead you can download and add the 1024 Bit key manually. If wget works you can do that in one step.

wget "http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x531EE72F4C9D234C" -O out && sudo apt-key add out && rm out

Otherwise safe "http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x531EE72F4C9D234C" in e.g. /path/key and use sudo apt-key add /path/key to add it.

Close with the usual

Afterwards you have to update the repository information apt-get update and then you should be able to download the packages.

Resources

My personal favorite on how to use the packaging mechanism (sadly in German): http://wiki.ubuntuusers.de/Paketquellen_freischalten/PPA

The launchpad version also mentions all the important points: https://help.launchpad.net/Packaging/PPA/InstallingSoftware

Since it is untypical to use apt-key in the described way I only found the information in the man pages, man apt-key.

Related answer that pretty much describes the standard way to install ppa's manually: http://askubuntu.com/a/38029/128349

share|improve this answer
    
apt-get was working behind the proxy, if you know any other workaround without using add-apt-repository, you can share. –  kenorb Feb 6 '13 at 13:17
    
@kenorb don't know if you get a notification if I edit my post, so: ping: "possible workaround" –  LeoR Feb 6 '13 at 19:21
    
Thanks, it looks great. Currently I don't have access to the machine where I had this problem, but I'll try the next time. But this this is something that should be fixed in add-apt-repository tool. –  kenorb Feb 7 '13 at 15:18
    
Thank you, so clear. –  shgnInc Jan 12 at 6:41
    
If your problem is that the port 11371 is blocked in your corporate firewall, you can now use the port 80 instead: "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4C9D234C" –  leszek.hanusz Feb 24 at 9:51
add comment

Actually it seems to be much easier than the answer posted previously. You just need "sudo" to know that you are behind a proxy and it will work effortlessly. To do this, you need to export your proxy for http and https the way you usually do:

export http_proxy=http://username:password@host:port/
export https_proxy=https://username:password@host:port/

and then add Defaults env_keep="https_proxy" to then end of /etc/sudoers file. After this you should be able to add the ppa using the command:

sudo add-apt-repository ppa:the_ppa_you_want_to_add

or use

sudo -E add-apt-repository ppa:the_ppa_you_want_to_add

if you don't want to modify /etc/sudoers file. The -E option exports environment variables to the sudo user.

I have given a detailed description about this here on my blog.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.