I'm experiencing exactly the same issue as described in this question: Kali Linux: apt-get update returns “Hash Sum mismatch” error. Before you mark this as a duplicate however, I have tried the solutions posted there, as well as on numerous other sites, including:
sudo apt-get clean sudo rm -rf /var/lib/apt/lists/* sudo apt-get update
/etc/apt/sources.list with alternate official mirrors, such as
deb http://mirrors.ocf.berkeley.edu/kali kali-rolling main non-free contrib or
deb https://http.kali.org/kali kali-rolling main non-free contrib
Everything worked after I first imported the VM. I ran
sudo apt update and it found some ~650 packages to upgrade. I ran
sudo apt upgrade and it encountered an error partway through. That error was solved using
sudo apt --fix-broken install, but that is when this hash sum error began. Unfortunately due to hours of troubleshooting I no longer have the details of the earlier error, but I believe it was an error extracting a package due to corrupt data.
I've tried multiple official mirrors, but I get the same error. Additionally, when I downloaded the Packages.gz file here on my Windows machine (VM host) and computed the SHA256 hash, I got the exact hash that
apt printed as the expected value. This led me to believe that the error was not with the mirror but with my VM.
The next thing I tried was
wget https://mirrors.ocf.berkeley.edu/kali/dists/kali-rolling/main/binary-amd64/Packages.gz followed by
sha256sum Packages.gz, which provided yet another different hash output.
To be clear, I have seen 3 different hashes for the same file:
- The "correct" hash shown by
aptas expected, which is the one that windows also produced after downloading the file using a browser
- The incorrect hash calculated by
apt, which led to the error
- A different hash calculated by
sha256sumafter downloading the file using
wgetusing the same URL as for the browser download
I should also note that I have only been referencing the SHA256 hash in each step. The other hash functions are also mismatched when I run
sudo apt update, but the file size is the same. I had considered that downloads might be failing due to limited disk space (it is a VM after all) but I don't think that's the case.
What am I missing?