Hi
@Ad-RWD,
short version: this looks like a bug in the CLI. I unpacked the current Git extension (2.5.12) from the Plesk catalog: its own CLI help says -remote-url is meant for "create" and "update", but the online docs list it for --create only. And in practice --update prints "was updated" and the UI still shows the old URL. Worth a ticket with Plesk support so it gets a bug ID, but don't wait for a fix with Dec 10 coming up. The brownouts are already running, so a failing pull right now is probably that.
Here's how I'd do it for many repos at once. Please run it on one subscription first.
1) Quick fix for every repo at once (git rewrites the URL itself)
The extension runs the normal system git as the subscription's system user, with Plesk's own SSH wrapper. git rewrites the URL before it even calls that wrapper, so it doesn't matter whether Plesk takes the URL from its database or from the repo config:
I'd keep this in place even after the cleanup below. Bitbucket's own "Clone" dialog still shows the old host, so people will keep adding repos with
[email protected].
2) Host keys
The Plesk Git extension doesn't use the normal known_hosts. Its SSH wrapper (/usr/local/psa/admin/sbin/modules/git/git_ssh) uses ~/.ssh/git_known_hosts of the system user, so usually /var/www/vhosts/<subscription>/.ssh/git_known_hosts. If there's no entry for the host yet, it grabs the key with ssh-keyscan and adds it without any check. I'd rather add verified keys myself. Atlassian's curl | sed one-liner isn't safe anymore, because /site/ssh now lists both hosts and the sed turns that into ssh.ssh.bitbucket.org. So:
Code:
ssh-keyscan -t rsa,ecdsa,ed25519 ssh.bitbucket.org 2>/dev/null > /root/ssh.bitbucket.org.keys
ssh-keygen -lf /root/ssh.bitbucket.org.keys
The fingerprints have to match the ones Atlassian published (same keys as before, just the new hostname):
SHA256:FC73VB6C4OQLSCrjEayhMp9UMxS97caD/Yyi2bhW/J0 (ECDSA)
SHA256:ybgmFkzwOSotHTHLJgHO0QN8L0xErw6vd0VhFA9m3SM (ED25519)
SHA256:46OSHA1Rmj8E8ERTC6xkNcmGOw9oFxYr0WF6zWW8l1E (RSA)
If they match, add them to every subscription that already uses SSH git. Appending keeps the file's owner and permissions:
Code:
for f in /var/www/vhosts/*/.ssh/git_known_hosts; do
ssh-keygen -F ssh.bitbucket.org -f "$f" >/dev/null || cat /root/ssh.bitbucket.org.keys >> "$f"
done
(If a repo runs under an additional FTP user, the file is in that user's home instead, e.g. /var/www/vhosts/example.com/sub.example.com/.ssh/.)
Then test with one repo (use the name shown by plesk ext git --list):
Code:
plesk ext git --fetch -domain example.com -name REPO_NAME
If that works, you're safe for Dec 10. The rest is cleanup so the UI shows the right URL.
3) Update the URL in the extension's database (this is what the UI shows)
The UI reads the URL from the extension's SQLite database. According to the schema in the extension package, it's in the column fetchUrl of the table Repositories.
Code:
DB=/usr/local/psa/var/modules/git/git_db.db
cp -a "$DB" "$DB.bak-$(date +%F)"
sqlite3 "$DB" "SELECT id, name, fetchUrl FROM Repositories WHERE fetchUrl LIKE '%bitbucket.org%';"
(On Rocky, if sqlite3 is missing: dnf install sqlite)
Then update:
Both statements only change the old URLs, so running them twice does no harm. Check the result with plesk ext git --info on one repo and in the UI.
4) Update the origin in each repo's git config
This loop handles both the git@ and the ssh:// form. git config doesn't edit the file in place: it writes config.lock and renames it. So if you run it as root, the config file ends up owned by root. The chown puts the original owner back. Dry run first, then remove the two # to apply:
If the dry run lists fewer repos than you expect, check where your repos actually live and adjust the glob.
About editing it by hand in the UI: as far as I know, the extension doesn't let you edit the remote URL of an existing repo. The only official way is to remove the repo and add it again (plesk ext git --remove / --create with the new -remote-url). For 300 repos I wouldn't do that. You'd have to re-enter the deployment path, mode and actions, and the webhook URL may change, so the Bitbucket webhooks would need updating too. Steps 1–4 avoid all of that.
Regards
Tessa