Server credential reset utility for Linux-based platforms

Plex Media Server User Credential Reset Utility

In light of the security event plaguing everyone, a ‘quick & dirty’ tool was crafted.

It’s a little rough around the edges but gets the job done.
It’s been evolving due to the need.

This tool,

  1. Removes the existing Username, Mail, Token, and PlexHome preference values from an existing Preferences.xml file leaving the server now suitable for claiming.

  2. Reclaims the server via a user-entered “Plex Claim Token” (obtained by visiting https://plex.tv/claim)

Currently supported platforms (more can be added)

  1. Linux (workstation & server)
  2. Synology (DSM 6 and DSM 7)
  3. QNAP (QTS and QuTS)
  4. Netgear ReadyNAS
  5. ASUSTOR
  6. Western Digital ( OS 5 – PR,DL, and Ultra - at this point
    (recommend using Public shared folder)
  7. Selected Docker containers
  8. Manual Path specification (which includes containers and custom) (See below)

How to use this tool.

  1. Stop Plex

  2. Place the tar file on the host and extract its contents. tar xf ./UserCredentialReset.tar. You will see file UserCredentialReset.sh

  3. Open a terminal window or SSH session to the host.

  4. If needed, using sudo, elevate your command line shell to root (admin on some machines

  5. Invoke the utility ./UserCredentialReset.sh

  6. It will confirm the host platform type (so it knows what to do)

  7. It will confirm you have sufficient user privilege and PMS is stopped

  8. It will then prompt for a “Plex Claim Token”.

  9. Open a browser tab to: https://plex.tv/claim

  10. COPY the given token

  11. WITHIN 4 Minutes, PASTE the token on the utility’s command line
    (The token expires so we need be quick)

  12. Hit Enter and it will immediately complete the task.

  13. When complete, It will verify all your credentials are valid and then update Preferences.xml for you

  14. It will print out your Plex username and email used in case you have multiple accounts.

  15. Utility then exits.

  16. Start PMS. It will be back to normal.

Conclusion

When you start PMS, it will already be claimed for you.
PMS will have no idea what happened while it was shut down :smiling_imp:

PLEASE don’t hesitate to ask if questions or issues.

How it looks in use

[~] # ./UserCredentialReset.sh            
 
          Plex Media Server user credential reset and reclaim tool (QNAP)
 
This utility will reset the server's credentials.  It will then reclaim the server for you via a Plex Claim tokem from Plex.tv
 
Please enter Plex Claim Token copied from http://plex.tv/claim : claim-G7Y7E4EqZkciJiRApeuL
Clearing Preferences.xml
Preferences.xml cleared
Getting new credentials from Plex.tv
Claim completed without errors.
 Username: ChuckPA
 Email:    ChuckIsCrazy@loonies.com
 
[~] #

Special consideration for NAS users without SSH capability.

  1. You can run the job as a scheduled task
  2. Instead of typing the Claim Token interactively, you can enter it on the command line.

Please observe:

[~] # ./UserCredentialReset.sh claim-GRiErLwrCnLY6tmJqFna
 
          Plex Media Server user credential reset and reclaim tool (QNAP)
 
This utility will reset the server's credentials.  It will then reclaim the server for you via a Plex Claim tokem from Plex.tv
 
Using claim token:  'claim-GRiErLwrCnLY6tmJqFna'
Clearing Preferences.xml
Preferences.xml cleared
Getting new credentials from Plex.tv
Claim completed without errors.
 Username: ChuckPA
 Email:    ChuckIsCrazy@loonies.com
 
[~] # 

Manual path: -p mode)

The utility now supports various installations (Docker, etc) by accepting the path to Preferences.xml directly on the command line.

This capability, enabled with the -p option on the command line,

  • Command line syntax:
./UserCredentialReset.sh  -p "/path/to/external/Preferences.xml" optional-claim-token-here

If -p (preferences path) is seen as the first command line argument,
it will expect the next argument to be the full path to Preferences.xml

It will verify the given file name exists and minimally contains some information found in a Preferences.xml file

It will continue to use this location and perform a normal claim action and store all output in the given pathname.

Given how containers work, it is not possible to validate anything further.
Proper use is the user’s responsibility.

Supplemental:

You may also invoke the script using sudo ./UserCredentialReset.sh. Linux should know to use /bin/sh as that’s in the magic bytes.

Also, sudo sh ./UserCredentialReset.sh is perfectly valid

( Isn’t Linux great? :smiling_face: )

(rev: 2022-08-31 19:30 UTC

  1. Support REMOTE servers
  2. Support all WD OS5 boxes
  3. Remove “access via LAN IP” requirement.

Please see the README.md f

ReadMe

UserCredentialReset.tar

15 Likes

Thanks! That worked for me after enabling SSH. One change to the procedure I made for my QNAP NAS was the command to issue was " sudo bash ./UserCredentialReset.sh"

This is GENIUS! Thank you for posting it. It did the job perfectly!

1 Like

Great work @ChuckPa - perhaps all our back and forth wasn’t in vain after all. Prevention better than cure now - you and @dane22 can actually do your day job again :stuck_out_tongue:

I am glad this works for you.

It’s a collection of things I’ve assembled from all my packaging and a new utility I am about to publish

3 Likes

How do you run it when using docker (Docker Hub)?

I can connect inside the container with bash but when trying to run the script it complains that PMS is running. Killing PMS with the pid does nothing since it automatically restarts.

I have a few synology nas’s some with dsm6 others withdsm7. In step 1 it says place the tar file… etc. where exactly are we placing the file if we haven’t started a ssh session yet.

You can place the tar file anywhere you want – including in the home directory you land in.

It doesn’t matter where the script itself is.

Once it detects the host type, it sets itself up and points directly at the data.

The most important thing to do is run with sudo privileges

Thanks @ChuckPa - I was really hopeful this would be the fix to my DSM 6 woes. I had followed a bunch of other attempts to reclaim my server but to no avail.

Having run the script, I got all the right signals coming from the script: saying everything had worked. However I am now unable to start the Plex server.

I am getting this error in the startup crash logs

Aug 26, 2022 12:00:25: Failed to initialize logging: Empty or non-existant file.

Any advice? Thanks

There is also another thread where is posted a Bighammer.sh , which should I be using? I am a linux novice like many I suspect so some very clear instructs with what to type would be very helpful to avert problems. In my case I tried both Bighammer.sh and the script mentioned on this thread and after copying the script and extracting to share/Public on the QNAP , logging in via SSH as admin I get file cannot be found??? Help please!

@rogc

Please point me to it?

I will edit and redirect here.
This thread is the finished script

@ChuckPa Once again you save my souse. The script worked 100%.

I just want to note that it could have been a bit easier to wget the script into the Linux box.
The short-link attached to the post throws back a 404 in ubuntu, when I use wget.

  1. But it works to click on it from the browser.
  2. Open with 7zip and open UserCredentialReset.sh with notepad.
  3. From there I copied the content.
  4. created a blank script “sudo nano UserCredentialReset.sh”
  5. Past in the content from clipboard.
  6. sudo chmod +x UserCredentialReset.sh
  7. sudo ./UserCredentialReset.sh

@vivid.water

What are you doing running NotePad on Linux? :scream: lol

The forum is set to click-download and get the right file name.
“wget” , when you are already here in the GUI ?? why?

The contents of the tar ball is already chmod 775

[chuck@lizum biggerhammer.788]$ tar tvf UserCredentialReset.tar 
-rwxrwxr-x root/root      7301 2022-08-26 08:55 ./UserCredentialReset.sh
[chuck@lizum biggerhammer.789]$
1 Like

Is there anything else around that error ?
I need more context.

Initial thought is something is wrong with the permissions in the Plex shared folder.

I’m having a problem with Putty. Got the Tar file extracted on my share folder.
Then when i run the sudo command I get No such file or directory even though I can clearly see the UserCredentialReset.sh file when i browse using WinSCP. Any help?

Genius, thanks for posting. it worked like a dream on my Synology DSM7.

Does this work for TrueNas users?

@adammallard23_gmail_com

I don’t currently have any “personality identification” for TrueNAS.

If you know the pathnames, I’ll work with you to quickly add the support for it.
Otherwise, I’ll have to make some time and setup a TrueNAS VM and do the exploration.

Which NAS are you using and where did you put the tar file?

I can give you customize instructions once I know those two pieces.