How to unlock `WD My Passport Drive` on Linux

By default WD My Passport Drive supports only Windows and OS X. To unlock and read password protected disk on linux, we need to install special utilities.

Get utils for WD My Passport Drive

  1. Install required packages:
  2.  Install py_sg library:
  3.  Download wd utils to your home directory:
  4.  Everything is ready ๐Ÿ˜‰

Unlock WD My Passport Drive

Unlock a locked drive. You will be asked to enter the unlock password. If everything is fine device will be unlocked. (To lock a drive, unplug it.)

  1. Plug in your password protected drive.
  2. Run in terminal this command and enter password:
    ~/wdpassport-utils.py --unlock

Change/create/remove password on WD My Passport Drive

  1. Plug in your drive.
  2. Run in terminal this command and enter password:
    ~/wdpassport-utils.py --change_passwd

Erase/reset WD My Passport Drive

Erase (reset) the drive. This will remove the internal key associated to you password and all your data will be unaccessible. You will also lose your partition table and you will need to create a new one (you can use fdisk and mkfs or other utilities to prepare and format the drive).

  1. Plug in your drive.
  2. Unlock device.
  3. Run in terminal this command:
    ~/wdpassport-utils.py --erase

Get list of available commands

  1. Run in terminal this command:
    ~/wdpassport-utils.py --help

I ask you to review this article

Rating 4.8 Stars from 52 reviews

33 thoughts on “How to unlock `WD My Passport Drive` on Linux”

    1. tengo una gran pregunta en el proceso 3 es nesesario digitar ese cd con el guion o solo lo que esta despues del punto y coma

      1. hello again, the previous command worked but now its saying “Something wrong opening device “””.

        1. Im getting the same error…

          WD Passport Ultra linux utility v0.1 by duke
          [!] Something wrong opening device

          I want to eventually mount this USB drive and share the content but dont want to have to run this script every time I reboot the box. If I fix the error above, could I get this added to my fedora boot somehow? /etc/fstab?

  1. Thanks for the script, however I’m getting an error:

    [radial@phraxis ~]$ ./wdpassport-utils.py -u
    File “./wdpassport-utils.py”, line 13
    except ImportError\, e:
    ^
    SyntaxError: unexpected character after line continuation character

    I’m running Manjaro 17.1.11 (i3), Python 3.6.6, pip 10.0.1 from /usr/lib/python3.6/site-packages/pip (python 3.6)

    Any help really appreciated ๐Ÿ™‚

    1. Hey Radial,
      How did you solved this error?
      $ ./wdpassport-utils.py -u
      File โ€œ./wdpassport-utils.pyโ€, line 13
      except ImportError\, e:

      Thanks in advance,
      Jorge

      1. Late answer: I got the same error, but the solution is to try running sudo ./wdpassport-utils.py -u
        With sudo it worked for me, no more error.

  2. Works great ! Thank you very much ๐Ÿ™‚

    I have encrypted the drive in Windows by utility from WD and I was able to unlock it by this script at Fedora 27.

  3. What about contacting WD if they want to include this into their official page ? I think many people would highly appreciate that and you could get some credit ๐Ÿ™‚

    Good job !

  4. This worked for me:
    :~$ sudo python2.7 ~/wdpassport-utils.py -u
    WD Passport Ultra linux utility v0.1 by duke
    [+] Insert password to Unlock the device
    Password:
    [*] Device unlocked.

    Cheers,
    Jorge

  5. Thanks, it works. Now is it possible to create a shortcut for the command? Otherwise everytime we have to open the terminal and type. Please tell me if it is possible.

  6. In linux mint 19.1 when I type: sudo pip install py_sg
    in the terminal I get an error message. Cannot locate py_sg package and cannot locate py_sg module.

  7. except ImportError, e:
    ^
    SyntaxError: invalid syntax
    It is showing this error on my Ubuntu 16.04

  8. This is the most fantastic thing EVER!. I have a 2TB drive that I bought 4 years ago and completely forgot the password. I only use Linux now and this worked perfectly. Hopefully WD gets the message and includes this on their page as previously stated.

  9. i have a problem after i run :
    sudo pip install py_sg

    it says :
    The directory ‘/home/amirmohammad/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
    The directory ‘/home/amirmohammad/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
    Collecting py_sg
    Downloading https://files.pythonhosted.org/packages/de/fe/aa8b849771ed622e0f734183fe4ddb84648ea017b2a08f308b04bbf779bf/py_sg-0.11.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
    File “”, line 1, in
    ImportError: No module named setuptools

    —————————————-
    Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-6G4rtB/py-sg/

    how can i fix it?

  10. hi , For those who have this error :
    $ ./wdpassport-utils.py -u
    File โ€œ./wdpassport-utils.pyโ€, line 13
    except ImportError\, e:
    you can run this command instead:
    $ sudo python wdpassport-utils.py -u

  11. Same error than Amirmohammad omidi:
    Traceback (most recent call last):
    File “”, line 1, in
    ImportError: No module named setuptools

    —————————————-
    Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-Y9y7m0/py-sg/

  12. I am running an extra internal HDD on my desktop for additional storage space. Access was initially direct, but at some stage and for reasons unknown to me, I had to enter my password to mount the drive. How do I revert to the original configuration where I had direct access to this drive? System is Ubuntu 16.04 Unity.

  13. Hello,
    All command worked correctly. However, when I type in the last one :
    ~/wdpassport-utils.py -u
    I receive the following message :
    bash: /home/SC/wdpassport-utils.py: Permission non accordรฉe

  14. @ Amirmohammad omidi & @ Alex Blanco
    Use “virtual environment” for Step 2:
    1 $ sudo apt install virtualenv –> Installation
    2 $ virtualenv myenv
    3 $ source myenv/bin/activate
    4 (myenv) $ pip install py_sg
    Then go further with Step 3

    For unlocking use:
    (myenv) $ sudo python ~/wdpassport-utils.py -u

  15. Hey, I have multiple hardrives and it is asking to specify the harddrive. How to do ?

    [!] Multiple occurences of “My Passport” detected. You should specify a device manually (with -d option).

  16. Thank you! this works great,

    I had the permission denial error at first then ran the chmod command then ran it again and worked!

    thanks again

Leave a Reply

Your email address will not be published. Required fields are marked *

nineteen − seven =