• Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below
  • Forum
  • Website
  • GitHub
  • Status
  • Translation
  • Features
  • Team
  • Rules
  • Help
  • Feeds
User Links
  • Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below

    Useful Links Forum Website GitHub Status Translation Features Team Rules Help Feeds
    Jellyfin Forum Support General Questions How to copy "Devices AccessToken" from an istance of Jellyfn to another?

     
    • 0 Vote(s) - 0 Average

    How to copy "Devices AccessToken" from an istance of Jellyfn to another?

    how to avoid need to re-authenticate users when using 2 jellyfin istances
    I-G-1-1
    Offline

    Junior Member

    Posts: 25
    Threads: 3
    Joined: 2023 Jun
    Reputation: 0
    #2
    2025-06-07, 04:24 PM (This post was last modified: 2025-06-07, 04:28 PM by I-G-1-1. Edited 3 times in total.)
    This work only if the "UserID" (not only the username) are the same for a specific username in the two Jellyfin istances.

    I use it with a NGINX reverse proxy configuration that redirect to istance B if istance A is offline.

    Here is the part of the NGINX configuration that handle the switch:
    Code:
    upstream backend {
        server [IPADDRESS_OF_ISTANCE_A]:8096 fail_timeout=5s max_fails=3;
        server [IPADDRESS_OF_ISTANCE_B]:8096 backup;
    }

    then in each location (/ and /socket) instead of using      
    Code:
    proxy_pass http://[IPADDRESS]:8096/;
    or
    proxy_pass http://[IPADDRESS]:8096/socket;
    use:
    Code:
    proxy_pass http://backend/;
    or
    proxy_pass http://backend/socket;



    Change [USER] and [IPADDRESS] with your data.

    on server A:

    sudo apt-get install sqlite3

    cd /home/[USER]
    nano export_accesstoken.sh

    Code:
    #!/bin/sh
    sudo sqlite3 /var/lib/jellyfin/data/jellyfin.db -cmd ".mode insert Devices" ".output /var/lib/jellyfin/data/accesstoken_data.sql" "SELECT * FROM Devices;" .quit
    sudo sed 's/^INSERT INTO/INSERT OR REPLACE INTO/g' /var/lib/jellyfin/data/accesstoken_data.sql > /var/lib/jellyfin/data/accesstoken_data_replace.sql
    sudo scp -i /root/.ssh/id_rsa_for_JFBK /var/lib/jellyfin/data/accesstoken_data_replace.sql [USER]@[IPADDRESS]:/home/[USER]/
    sudo rm -f /var/lib/jellyfin/data/accesstoken_data.sql
    sudo rm -f /var/lib/jellyfin/data/accesstoken_data_replace.sql
    sudo /usr/bin/ssh -i /root/.ssh/id_rsa_for_JFBK [USER]@[IPADDRESS] "sudo /usr/bin/sh /home/[USER]/import_accesstoken.sh"
    exit 0

    sudo ssh-keygen -f /root/.ssh/id_rsa_for_JFBK

    vi /root/.ssh/id_rsa_for_JFBK.pub --> copy the key to /home/[USER]/.ssh/authorized_keys on server B


    on server B:

    sudo apt-get install sqlite3

    cd /home/[USER]
    nano import_accesstoken.sh

    Code:
    #!/bin/sh
    sudo systemctl stop jellyfin
    sleep 20
    sudo sqlite3 /var/lib/jellyfin/data/jellyfin.db "DELETE FROM Devices;"
    sudo sqlite3 /var/lib/jellyfin/data/jellyfin.db < /home/[USER]/accesstoken_data_replace.sql
    sleep 5
    rm /home/[USER]/accesstoken_data_replace.sql
    sudo systemctl start jellyfin
    exit 0

    sudo chown root:root /home/[USER]/import_accesstoken.sh
    sudo chmod 700 /home/[USER]/import_accesstoken.sh

    sudo visudo /etc/sudoers.d/[USER]
    Code:
    Cmnd_Alias [USER]_CMDS = /usr/bin/sh /home/[USER]/import_accesstoken.sh
    [USER] ALL=(ALL:ALL) NOPASSWD: [USER]_CMDS

    on server A run
    Code:
    sudo /home/[USER]/export_accesstoken.sh

    now server B has the same accesstoken of server A
    « Next Oldest | Next Newest »

    Users browsing this thread: 1 Guest(s)


    Messages In This Thread
    How to copy "Devices AccessToken" from an istance of Jellyfn to another? - by I-G-1-1 - 2025-06-07, 10:16 AM
    RE: How to copy "Devices AccessToken" from an istance of Jellyfn to another? - by I-G-1-1 - 2025-06-07, 04:24 PM

    • View a Printable Version
    • Subscribe to this thread
    Forum Jump:

    Home · Team · Help · Contact
    © Designed by D&D - Powered by MyBB
    L


    Jellyfin

    The Free Software Media System

    Linear Mode
    Threaded Mode