• The new Python extension is now available. It allows customers to deploy and manage WSGI-based Python applications on their websites directly from Plesk.
  • The Plesk Mobile apps for iOS and Android and the Plesk Mobile Center extension have been deprecated, and are no longer available for new installations. In Plesk Obsidian 18.0.84, the Plesk Mobile Center extension will be removed from servers during the upgrade, and the Plesk Mobile apps will lose their server management features.
  • The Social Login extension has been deprecated and will be removed in Plesk Obsidian 18.0.84. After that, it will no longer be possible to log in to Plesk with a Google, Facebook, GitHub account, or with a passkey. Plesk usernames and passwords, as well as logging in with a WebPros Account, are not affected.

Issue Mass update git remote-url

tsaya

New Pleskian
Server operating system version
Rocky Linux 8.10
Plesk version and microupdate number
18.0.81
Bitbucket cloud recently announced this Upcoming change to Bitbucket Cloud SSH access: move from bitbucket.org to ssh.bitbucket.org - Atlassian ,

we have 300 repositories and need to update remote urls . I tried on one domain and repo using cli like this

Code:
plesk ext git --update -domain mydomain.tld -name mydomain.git   -remote-url [email protected]:myaccount/myrepo.git

Code:
The repository "mydomain.git" was updated.

but nothing changes in UI . Has any body found solution/workaround to this issue ?
 
Hi,

I haven’t tested this on Plesk 18.0.81, so please try it on a single repo first.

First, check what the repository itself has stored (the default path is assumed, adjust it if yours differs):

Code:
for d in /var/www/vhosts/*/git/*.git; do echo "$d: $(git --git-dir="$d" config --get remote.origin.url)"; done

If this already shows the new URL, the CLI update worked and the UI is probably showing a stored value that doesn’t get refreshed. If it still shows the old URL, the CLI only changed Plesk’s own record.

If you want to change all repos directly in the git config, this prints the planned changes. Uncomment the last command to apply them:

Code:
for d in /var/www/vhosts/*/git/*.git; do
u=$(git --git-dir="$d" config --get remote.origin.url)
case "$u" in
[email protected]:*)
echo "$d: $u -> [email protected]:${u#[email protected]:}"
# git --git-dir="$d" config remote.origin.url "[email protected]:${u#[email protected]:}"
;;
esac
done

If you run it as root, check the ownership of <REPO>/config afterwards (ls -l) and reset it to the domain’s system user if needed. Don’t forget that ssh.bitbucket.org must be in known_hosts of each system user, otherwise fetch/deploy fails on the host key check. Verify the fingerprint against Atlassian’s published keys before accepting it. I don’t know where the UI reads its value from, so if it still shows the old URL after this, it’s worth asking Plesk support.

Regards
Tessa
 
Hi,

I haven’t tested this on Plesk 18.0.81, so please try it on a single repo first.

First, check what the repository itself has stored (the default path is assumed, adjust it if yours differs):

Code:
for d in /var/www/vhosts/*/git/*.git; do echo "$d: $(git --git-dir="$d" config --get remote.origin.url)"; done

If this already shows the new URL, the CLI update worked and the UI is probably showing a stored value that doesn’t get refreshed. If it still shows the old URL, the CLI only changed Plesk’s own record.

If you want to change all repos directly in the git config, this prints the planned changes. Uncomment the last command to apply them:

Code:
for d in /var/www/vhosts/*/git/*.git; do
u=$(git --git-dir="$d" config --get remote.origin.url)
case "$u" in
[email protected]:*)
echo "$d: $u -> [email protected]:${u#[email protected]:}"
# git --git-dir="$d" config remote.origin.url "[email protected]:${u#[email protected]:}"
;;
esac
done

If you run it as root, check the ownership of <REPO>/config afterwards (ls -l) and reset it to the domain’s system user if needed. Don’t forget that ssh.bitbucket.org must be in known_hosts of each system user, otherwise fetch/deploy fails on the host key check. Verify the fingerprint against Atlassian’s published keys before accepting it. I don’t know where the UI reads its value from, so if it still shows the old URL after this, it’s worth asking Plesk support.

Regards
Tessa

Here's a small addendum to my previous post, in case you're interested in where the UI reads its data from:

The Plesk UI doesn’t read from the repository’s git config. It reads from the SQLite database of the Git extension, located at /usr/local/psa/var/modules/git/git_db.db, in the table Repositories. A Plesk KB article shows that each row there holds the remote URL (e.g. [email protected]:repo/repo.git) and that the table can be queried with the sqlite3 client: https://support.plesk.com/hc/en-us/articles/12376956339479

I haven’t verified this on a live server, and I don’t know the exact name of the URL column, so please check the schema first and test on a single repo.

Backup and schema:
Code:
cp -a /usr/local/psa/var/modules/git/git_db.db /usr/local/psa/var/modules/git/git_db.db.backup
sqlite3 /usr/local/psa/var/modules/git/git_db.db ".schema Repositories"

List the affected entries. The column containing the bitbucket URLs is the one you want:
Code:
sqlite3 /usr/local/psa/var/modules/git/git_db.db "select * from Repositories where instr(remoteUrl, 'bitbucket.org') > 0;"

If the column is named differently, replace remoteUrl with the name from the schema. Then test the update on a single repo first. Placeholder in capitals:
Code:
sqlite3 /usr/local/psa/var/modules/git/git_db.db "update Repositories set remoteUrl = replace(remoteUrl, '[email protected]:', '[email protected]:') where id = REPO_ID;"

If that works, update all of them:
Code:
sqlite3 /usr/local/psa/var/modules/git/git_db.db "update Repositories set remoteUrl = replace(remoteUrl, '[email protected]:', '[email protected]:') where remoteUrl like '[email protected]:%';"

Afterwards:
The git config of each repo still has to be changed separately (see my loop above), otherwise Plesk keeps pulling from the old URL.
ssh.bitbucket.org must be in the known_hosts of each system user.
Verify the host key fingerprint against Atlassian’s published keys before accepting it.

Regards
Tessa
 
Also have this issue, need to update various git URLs to ssh.bitbucket.org. Would be good if there was a way to do this en masse, or at very least be able to edit manually or in the plesk extension which at the moment isn't working in the CLI.
Any chance this could be looked into why the CLI line isn't working correctly, if there is a way to bulk update it, or a way to manually edit from the Plesk interface? Ideally before the Dec 10th shutdown date on bitbucket
 
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:

Code:
git config --system url."[email protected]:".insteadOf "[email protected]:"
git config --system url."ssh://[email protected]/".insteadOf "ssh://[email protected]/"
git config --system --get-regexp '^url\.'

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:

Code:
sqlite3 "$DB" "UPDATE Repositories SET fetchUrl = replace(fetchUrl, '[email protected]:', '[email protected]:') WHERE fetchUrl LIKE '[email protected]:%';
UPDATE Repositories SET fetchUrl = replace(fetchUrl, 'ssh://[email protected]/', 'ssh://[email protected]/') WHERE fetchUrl LIKE 'ssh://[email protected]/%';"
sqlite3 "$DB" "SELECT id, name, fetchUrl FROM Repositories WHERE fetchUrl LIKE '%bitbucket.org%';"

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:

Code:
for d in /var/www/vhosts/*/git/*.git; do
  u=$(git --git-dir="$d" config --get remote.origin.url) || continue
  case "$u" in
    [email protected]:*)       n="[email protected]:${u#[email protected]:}" ;;
    ssh://[email protected]/*) n="ssh://[email protected]/${u#ssh://[email protected]/}" ;;
    *) continue ;;
  esac
  echo "$d: $u -> $n"
  # git --git-dir="$d" config remote.origin.url "$n"
  # chown --reference="$d" "$d/config"
done

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
 
Last edited:
Back
Top