We are back with another discussion on
apt related errors and this time, we are talking about an error message which looks like the following:
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
You might have encountered this error while trying to run the
apt update or the
apt upgrade command. This is one of the more problematic errors in Linux as it prevents the user from updating either some programs or even the operating system itself. Sometimes, the error is accompanied by another message which looks like the following:
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg
If you are also getting the above error message, we would suggest you go through this article.
Reasons behind this error
This error again has a lot to do with the sources.list file present in the etc/apt/ directory. Having outdated sources is the primary reason why this error occurs. Also, as the name suggests, this error occurs when the repositories your OS is supposed to update from are identified as insecure and can pose a threat to the system.
In case you are using an EoL (End of Life) version (A distro version which is no longer supported and is considered obsolete), you will also get the before-mentioned “failed to fetch” error so you can head over to that article to find out how you can upgrade from an EoL distro to a current LTS (Long Term Support) version.
Another significant case for the error is when you are using a repository which is not trusted (generally from third-party sources) by Linux. Hence, they are disabled as a security measure.
How to fix the problem?
Method 1: Bypass the safeguard
If you trust the software that you are installing using apt, you can actually bypass the authentication safety measures and allow the package to be installed without getting the said error.
Just use the following options:
For example, if you want to install bc (Basic Calculator) with the above options using apt, you need to write the command like this:
Method 2: Adding unsigned repository with a flag
If you are using an unsigned repository, you might be getting this error as unsigned repositories usually get flagged as insecure. To use the repository, you will need to add an option to it in your
sources.list file. Follow the steps below:
1. Open the
sources.list file using a text editor, I will be using the vi editor:
sudo vi /etc/apt/sources.list
2. Add the following option to the source you are using:
For example, I have set the
trusted option for the
http://archive.ubuntu.com/ubuntu/ jammy main restricted source like the following:
3. Save and exit using the ESC key then
:wq! (for vi editors).
4. Run a
sudo apt-get update command and see if the problem is resolved.
Alternatively, you can also try adding the
Method 3: Disable the repositories that are causing trouble
When you get the “
Updating from such a repository can't be done securely“, the repository source is also mentioned along with the error code. This repository source is the cause of the problem and we can work around it by disabling that repository. To do that, follow the steps mentioned below:
1. Open the software updater
2. Under the Other Software tab, find the concerned repositories and uncheck them
3. Close the software updater and run the following command:
sudo apt update
This should resolve the problem with the installation/update.
Fixing this error was not much complex when compared to other errors related to the apt utility. This error occurs from a very specific cause and hence there are just a few methods available to solve it which work most of the time. If the error is still not resolved even after following the methods described above, you might need to find alternative ways to install the package which you may find on its source website.