Error Re-claiming Server via UserCredentialReset

This morning, my plex media was showing up for all users EXCEPT the admin. I googled THIS solution which users had said help solve the issue.

So I shut down PMS and then (foolishly) deleted the PlexOnlineHome, PlexOnlineMail, PlexOnlineToken and PlexOnlineUsername entries from the Preferences.xml file (I’m running PMS on Ubuntu) without backup. When I fired PMS back up, went to localhost, and clicked “claim server” on my server… the wheel spins, then the “claim server” button just reappears.

I am hoping @ChuckPa 's UserCredentialReset tool can save me, but upon running the script, I get the following message:

./UserCredentialReset.sh: line 1: synoshare: command not found
awk: warning: escape sequence `\[' treated as plain `['
awk: warning: escape sequence `\]' treated as plain `]'
./UserCredentialReset.sh: line 1: getcfg: command not found
./UserCredentialReset.sh: line 1: cd: /etc/systemd/system/plexmediaserver.service.d: No such file or directory
stat: cannot statx '""': No such file or directory
stat: cannot statx '""': No such file or directory
./UserCredentialReset.sh: line 1: \,: command not found
./UserCredentialReset.sh: line 1: \,: command not found
./UserCredentialReset.sh: line 1: \,: command not found
cat: '""': No such file or directory
sed: -e expression #1, char 39: unknown option to `s'
sed: -e expression #1, char 33: unknown option to `s'
sed: -e expression #1, char 63: unknown option to `s'
./UserCredentialReset.sh: line 1: payload:allShortcutsEnabled:false: command not found

Anyone have any insight to re-claiming my server?

@Blockguster

Did you use a Windows text editor / a Windows computer ??

Which Linux distro and version are you using?

I did not. Downloaded the script direct to the server (running Ubuntu 22).

The file is clearly corrupted if line 1 references synoshare

[chuck@lizum UserCredentialReset.2003]$ ls -la
total 24
drwxrwxr-x  3 chuck chuck    83 Jan  3 23:36 ./
drwxr-xr-x 10 chuck chuck   282 Aug  9 22:08 ../
drwxrwxr-x  7 chuck chuck   204 Jan 10 00:53 .git/
-rw-r--r--  1 chuck chuck   974 Dec 24  2022 LICENSE.md
-rw-r--r--  1 chuck chuck  6644 Jan 10 00:53 README.md
-rwxr-xr-x  1 chuck chuck 10786 Jan  2 21:12 UserCredentialReset.sh*
[chuck@lizum UserCredentialReset.2004]$ vi UserCredentialReset.sh 
[chuck@lizum UserCredentialReset.2005]$ sudo ./UserCredentialReset.sh 
 
          Plex Media Server user credential reset and reclaim tool (Ubuntu 20.04.6 LTS)
 
This utility will reset the server's credentials.
It will next reclaim the server for you using a Plex Claim token you provide from https://plex.tv/claim
 
ERROR:  PMS is running.  Please stop PMS and try again
[chuck@lizum UserCredentialReset.2006]$ 

Here is a tar file.
UserCredentialReset.tar (20 KB)

Thank you. Sure enough, the tar file version worked.
However, when running the script, I get the following:

ERROR: Could not get credentials from plex.tv (Error: 60)

Ah, you have your own certificate -OR- date/time is out of sync with the internet time daemons.

In most cases, it’s because the clock is out of sync.

Out-of-sync clock will stop everything (SSL won’t lock up)

I do have an SSL certificate on the server…
and my server’s clock appears to be correct (although set to UTC… it is located in EST/EDT)

So is it the SSL that’s causing an issue?

Curl error 60

cURL error 60 usually means that there is a problem with the configuration of the SSL on the server you are trying to connect to . One issue that might be occurring is that the host name used in the request does not match any host name shown on the SSL.

Your host is probably a FQDN and Plex.tv doesn’t have your cert
(Only PMS locally will but it’s not active right now)

This host is remote?

If remote, and you have SSH access to it, we’ll go to the direct CURL level and let PMS negotiate on its own. (let me know please)

The domain is hosted by GoDaddy. I assume that’s what you are looking for?
The SSL is issued by NameCheap

Do you have SSH access ?

Assuming you do –

  1. SSH to the host

  2. sudo bash (get root)

  3. cd “/var/lib/plexmediaserver/Library/Application Support/Plex Media Server”
    (or wherever you might have moved it)

  4. Using your favorite Linux text editor (nano, vi, etc), Carefully remove the following
    Name="Value" pairs
    – PlexOnlineUsername
    – PlexOnlineToken
    – PlexOnlineMail
    – PlexOnlineHome (if it exists)

  5. Save the file

  6. Start PMS (it will sit there quietly and wait to be claimed in the next step)

  7. Open a browser tab to https://plex.tv/claim and COPY the token it gives you

  8. Return to the SSH session.

curl -X POST 'http://127.0.0.1/myplex/claim?token=PASTE_TOKEN_HERE'
  1. Hit enter and wait a bit.

  2. It will respond with a flurry of XML in about 20-30 seconds.

This confirms the server is reclaimed to you.

NOTE: I will see what I can do with my script to work with FQDN hostnames.

Ah yes, I understand what you meant haha.
Yes I can SSH in. here is what I got after following those steps…

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://**my domain**/myplex/claim?token=claim-ELBT2Ez2dF1aPUJ4oAyi">here</a>.</p>
<hr>
<address>Apache/2.4.52 (Ubuntu) Server at 127.0.0.1 Port 80</address>
</body></html>

MY mistake! :man_facepalming:

the correct url http://127.0.0.1:32400/myplex/claim?token=PASTE_TOKEN_HERE

I forgot the port. It went to your apache server instead.

I am very sorry

Please get a fresh claim token and hit the endpoint again.

No worries. Refreshed token, added port and still no dice…

<html><head><title>Internal Server Error</title></head><body><h1>500 Internal Server Error</h1></body></html>

When that happens either:
a) PMS locked itself down (needs prefs cleaned again)
b) token expired
c) token didn’t make it into the -X POST ‘http://…’ (escaped or quoted for the ‘?’)

It wouldn’t hurt to shut it down , make sure it’s clean and redo it again EXCEPT for my gaff on the port number

FQDN’s are fussy. When you have stuff playing with the sockets, I know plex.tv doesn’t like anything interfering with its cert (which is why PMS barks so much)

NOTE: I’m looking at the FQDN problem. I have an idea about having CURL temporarily add your cert for the plex.tv interaction.

I don’t know yet.

Worst case, We take the hostname out of the domain and then claim.

Thanks again for taking the time to help.

I shut down PMS, wiped the necessary key-value pairs, saved, fired up PMS and ran the CURL (with port) with fresh token correctly inserted into the url (no escape or quote for the ?)… It thought about it for 5-10 seconds then shot out the same 500 Internal Server Error message.

Just to be clear, I am supposed to remove not only the value from the .xml but also the key itself, correct?

Yes, you are supposed to remove the Name="Value" entire preference pair.

If you had PlexOnlineToken="", you would get an error every time.

I put quotes around the whole URL so I don’t have to escape the ?

curl -X POST ‘http://127.0.0.1:32400/myplex/claim?token=PASTE_TOKEN_HERE

This protects the entire URL as it goes into curl otherwise the filesystem will try to glob for a filename match (which will fail)

Ok, in that case, I believe I’ve followed your directions to a T. Still getting the 500 error

OK… BFH time…

  1. Stop plex
  2. Rename Preferences.xml → Preferences.xml-SAVED
  3. Get new token (make sure it’s different… they do last for 5 minutes)
  4. Start up
  5. Give it a second (5-10)
  6. Now hit the CURL endpoint

This will create a new server instance BUT it will confirm if it’s the surrounding SSL / FQDN work interfering or not.

We’re looking for it to successfully claim. We’ll deal with the aftermath after claiming.

(did you add your extras before of after PMS was up and running ?)

Alright, followed that with brand spanking new token and still getting the 500. Must be the SSL/FQDN.

Not sure I understand your last question though. Which extras?