Kali Linux 2024.2执行apt更新升级时出现403 Forbidden错误的求助
Hey Mohammad, sorry to hear you're stuck with this 403 Forbidden error while trying to update your new Kali 2024.2 system. Let's work through some practical fixes to get your updates running smoothly:
Fix your sources.list configuration first
The error mentions the repo isn't signed and you're hitting a 403, which usually points to outdated or incorrect repo sources. Let's start by fixing this:- Back up your current sources list to avoid messing things up:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak - Edit the sources file with a text editor (nano is beginner-friendly):
sudo nano /etc/apt/sources.list - Clear out all existing lines and paste in the official HTTPS sources (note we're including
non-free-firmwareto match the component change notice you saw):deb https://http.kali.org/kali kali-rolling main non-free non-free-firmware deb-src https://http.kali.org/kali kali-rolling main non-free non-free-firmware - Save and exit: Press
Ctrl+O, hit Enter to confirm, thenCtrl+Xto close nano.
- Back up your current sources list to avoid messing things up:
Clear stale APT cache and re-run updates
Old cached data might be causing conflicts. Let's wipe it and start fresh:- Clean the local cache:
sudo apt clean - Try updating again:
sudo apt update - If you still see errors about missing files, run this to fix broken dependencies and missing repo data:
sudo apt update --fix-missing
- Clean the local cache:
Check for network or proxy issues
A 403 error can sometimes be caused by network restrictions (like a company firewall, campus network, or even a misconfigured proxy). Let's verify connectivity:- Test if you can reach the Kali repo server:
curl -I https://http.kali.org/kali/dists/kali-rolling/InRelease - If you get a
403 Forbiddenhere too, your network might be blocking access. Try switching to a regional mirror. Replace the sources insources.listwith something like:deb https://mirrors.aliyun.com/kali kali-rolling main non-free non-free-firmware - Make sure you don't have an unwanted proxy set up. Check for proxy variables with
echo $http_proxyandecho $https_proxy— if they return values you didn't set, unset them withunset http_proxyandunset https_proxy, then try updating again.
- Test if you can reach the Kali repo server:
Verify your system time is correct
Incorrect system time can break repo signature verification. Let's sync your clock to the network:sudo timedatectl set-ntp trueCheck if the sync worked with:
timedatectl statusLook for "System clock synchronized: yes" in the output.
If you've tried all these steps and still run into issues, share the output of the curl command and any new error messages you get — that'll help narrow down the problem further.
备注:内容来源于stack exchange,提问作者Mohammad dehghani

