tenseiken / docker-qbittorrent-wireguard

Docker container which runs qBittorrent-nox (headless) client while connecting to WireGuard.
GNU General Public License v3.0
15 stars 5 forks source link

Very nice project thank you :) #1

Closed Pondiniii closed 6 months ago

Pondiniii commented 6 months ago

Thank you for publishing this project and for your hard work. Now I can seed my Linux ISOs. 😁

I discovered that the default password 'adminadmin' does not work because, in the latest qBittorrent-nox version, the password is generated randomly at the first start.

To fix it, I had to use this Python script:

import hashlib
import base64
import uuid

password = input("Please enter new qBittorrent password: ")
password_bytes = password.encode()
salt = uuid.uuid4().bytes
hashed_password = hashlib.pbkdf2_hmac('sha512', password_bytes, salt, 100000, dklen=64)

b64_salt = base64.b64encode(salt).decode("utf-8")
b64_password = base64.b64encode(hashed_password).decode("utf-8")

password_string = f'WebUI\\Password_PBKDF2="@ByteArray({b64_salt}:{b64_password})"'
print(password_string)
print('\n\nEdit qBittorrent.conf in your Docker volume.')

To implement this fix:

  1. Turn off the container.
  2. Add this line (generated using my python script) WebUI\\Password_PBKDF2="@ByteArray({b64_salt}:{b64_password})" in the volume qBittorrent/config/qBittorrent.conf under [Preferences].
  3. Start the container.

I am willing to contribute to this project. I think we can edit this bash if statement to regenerate qBittorrent.conf at every start, using the environment variable WEBUI_USER.

tenseiken commented 6 months ago

Thanks for your kind words. 😁

This was on my radar at some point, but I guess since I already have an established config file it slipped my mind. I do like the idea of being able to set a password outside of qBittorrent for the first run, but I'd prefer not to add a Python dependency as that would increase the size of the image pretty substantially.

As a compromise, what if we hashed/salted the default "adminadmin" password with your script and added the WebUI\Password_PBKDF2 line into the template config file? That way if the config file is not present, the template is dropped into place, the user can login with admin/adminadmin for their first time, and then they can set a new user/pass from the qBittorrent web UI?

Pondiniii commented 6 months ago

Ok, I agree, Python is quite bloated. I tried porting this Python script to a shell script, but I couldn't do it. I will try again tomorrow. For now, we can just edit the default qBittorrent.conf file, just like that:

[BitTorrent]
Session\BTProtocol=Both
Session\DefaultSavePath=/downloads
Session\TempPath=/downloads/temp
Session\TempPathEnabled=true
Session\UseRandomPort=true
Session\Port=8999

[Preferences]
WebUI\Username=admin
WebUI\Password_PBKDF2="@ByteArray(ARQ77eY1NUZaQsuDHbIMCA==:0WMRkYTUWVT9wVvdDtHAjU9b3b7uB8NR1Gur2hmQCvCDpm39Q+PsJRJPaCU51dEiz+dTzh8qbPsL8WkFljQYFQ==)"
WebUI\Port=8080
WebUI\HostHeaderValidation=false

This hash defaults to adminadmin.

Later, we can update the readme for others on how to change the password with Python if I am not successful with porting this Python script to a shell script.

I am not sure if this update to the qBittorrent.conf file will work fine with your Proton VPN forward VPN servers.

tenseiken commented 6 months ago

I actually used your script to generate the hash and tested it out. See 92eba07 for the details. I pushed the updated image to the Docker repo as well.

If you do find a way to make this happen in bash, let me know or just send a PR.

This shouldn't affect port forwarding as that all happens in portfwd.sh, running in the background. I have been having a problem with port forwarding yesterday and today, but I think it's on Proton's side. Opened a ticket with them already.

Pondiniii commented 6 months ago

I've just compiled the Docker image and it works great! Thank you so much for the collaboration. It was a pleasure working with you!