How to add public key in apt-get

Default featured post

Many times it happens for me that I add a new repository but when I wanted to update my repositories with “sudo apt-get update” command I faced with below error.

W: GPG error: precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 2EBC26B60C5A2783

 This error indicates that the repository (in this example is not authorized and does not have public key. Solving such a problem is quite easy to solve and actually does not need a long post.
Firstly, you need to write following command,

$ sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring

Keep in your mind that you should change the last parameter (medibuntu-keyring) of the above command based on your need. The mentioned command is apt-get but with different parameters. Overall, the above command tells system to give authority to unauthenticated repository plus add public keys.
Now all you need to do after above command to update your repositories once more with below command,

$ sudo apt-get update

Now, you can install and update packages from your new added repositories without any issue.