GPG Error : Invalid Signatures

I have fresh installation of ubuntu 14.04 now. When I updated my system, I faced the following GPG Error:

W: GPG error: trusty Release: The following signatures were invalid: BADSIG 40976EAF437D05B5 Ubuntu Archive Automatic Signing Key <>

As it is saying that “BADSIG 40976EAF437D05B5” signature is invalid. To solve this, I run the following command to import the keys:

sudo apt-key adv --keyserver --recv-keys 6AF0E1940624A220 40976EAF437D05B5


  1. apt-key: It is used to manage the list of keys used by apt to authenticate packages. Packages which have been authenticated using these keys will be considered trusted.
  2. adv: Pass advanced options to gpg. With adv –recv-key you can download the public key.
  3. For more details, read

But, it didn’t solve the issue. Then, I found a trick to remove this error. This was like given below:

Open your source.list using your favorite text editor, i.e.

$ sudo vim /etc/apt/sources.list

locate and replace it with

So, I remove the ‘in.’ prefix in each of the addresses to convert them to addresses of the main server. This solved my problem.

We may also use the following command for fast editing:

sudo sed -i 's/http:\/\/in./http:\/\//g' /etc/apt/sources.list

Replace ‘in’ by any other mirror you are using.


Explanation of command:

  1. sed – stream editor for filtering and transforming text.
  2. The -i argument is to edit a file in place.
  3. Then ‘s/regexp/replacement/g’, s specifying the search and replace command.
  4. The g at the end being the argument to “globally” search.
  5. The forward slash is the delimiter between the command and arguments except where it is escaped with a backslash.

We can also do this in “Softwares & Updates” center.

P.S. Also, read this:


Published by


I am the one who discover myself daily through reading, writing, interacting with people and expressing my thoughts to inspire them if I would be able to bring a little change to the society through my work. I write blogs, participate in various social activities and want to be a Professional Speaker. Currently, I am pursuing my post graduation in Computer Applications from Guru Nanak Dev Engineering College, Ludhiana and I’m very much active in many technical & social communities.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s