I have a mount from Linux to a windows network drive that works great. Except for one thing: every 90 days my password changes and I have to go in and recreate the mount like so:

sudo mount -t cifs \
    -o 'vers=3.0,username=USER,domain=ads-domain,password=PASSWORD' \
    '//' \

Works great but I don't want to keep recreating it. can I use a credentials file like this:

9.2.4. Authenticating To an SMB Share Using a Credentials File

vi ~/smb.cred
# Set the permissions to only allow the owner to access the file:
chown user_name ~/smb.cred
chmod 600 ~/smb.cred

Or I already have an .env file in ~ that my python stuff uses. could I do something really weird like this?

sudo mount -t cifs \
    -o 'vers=3.0,username=USER,domain=ads-domain,password=$(python get_password_from_env.py USER)' \
    '//' \

I don't know. What's the best way to make the credentials dynamic here?

  • 1
    Have you considered using autofs with Kerberos authentications? If you have Kerberos tickets (from login or with kinit periodically) autofs can use it for mounting the volume. No need to store your password in plaintext. – jsbillings Apr 30 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.