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.

apt-get does not work the first time but works the second time.

I installed ntp like:

apt-get -q -y install ntp=1:4.2.6.p3+dfsg-1ubuntu3.1

It failed saying:

WARNING: The following packages cannot be authenticated!
  libcap2 libopts25 ntp
E: There are problems and -y was used without --force-yes

Afterwards I ran:

apt-key update

and ran the same commad with --force-yes:

apt-get -q -y --force-yes install ntp=1:4.2.6.p3+dfsg-1ubuntu3.1

Thereafter running apt-get purge and reinstalling, ntp runs.

apt-get purge libcap2 libopts25 ntp  
apt-get -q -y install ntp=1:4.2.6.p3+dfsg-1ubuntu3.1

Also I created a fresh VM and could not reproduce the issue. On a fresh VM, the same apt-get command runs the first time, without --force-yes.

Two questions, why does running apt-get work the second time and cannot reproduce the error?

Full errors and sequential steps at https://gist.github.com/3017966.

share|improve this question
    
Possibly related question: askubuntu.com/questions/1877/… –  medigeek Jul 5 '12 at 11:16
add comment

1 Answer 1

up vote 2 down vote accepted

Try this on your server (or use sudo for desktops):

apt-key net-update
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 437D05B5
apt-get update
apt-get install ntp=1:4.2.6.p3+dfsg-1ubuntu3.1

The two apt-key commands will refresh the key. If you want to iterate over all your apt-key keys:

sudo apt-key adv --keyserver keyserver.ubuntu.com --verbose --refresh-keys

You should always apt-get update before you apt-get install some-package.

I think the basic problem is that you haven't used apt-get update for a while, the key got old probably and had to be checked/refreshed (I'm not 100% sure though).

share|improve this answer
    
@mediageek can i run apt-key adv --recv-key rather than apt-key adv --keyserver keyserver.ubuntu.com --recv 437D05B5. Also how did you find the key 437D05B5 ? –  deepak Jul 5 '12 at 8:45
    
@mediageek another problem is that, i am no longer able to reproduce the issue, even on a new vm. can i update the apt database to an older version and reproduce the issue ? –  deepak Jul 5 '12 at 8:47
    
I think the basic problem is that you haven't used apt-get update for a while, the key got old probably and had to be checked/refreshed (I'm not 100% sure though). The key 437D05B5 is from the ubuntu keyserver, I compared from my own sudo apt-key list. I'll fix the command, you're right, use --recv-key. If you can't reproduce the problem, then it's solved. :) –  medigeek Jul 5 '12 at 8:54
    
@mediageek i will have to iterate over the keys in apt-key list. Is there a simpler way to update all keys ? Also, what is the difference between net-update and adv --recv-key ? –  deepak Jul 5 '12 at 9:20
    
I have no idea frankly, but if one command fails, the other one works. Manpage: manpages.ubuntu.com/manpages/precise/en/man8/apt-key.8.html If you want to iterate over all your apt-key keys use: sudo apt-key adv --keyserver keyserver.ubuntu.com --verbose --refresh-keys –  medigeek Jul 5 '12 at 10:19
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.