I have a network share I mount on a Linux-computer using the following command:

sudo mount -t cifs -o credentials=/path/to/credentials,uid=1000,gid=1000,file_mode=0600,dir_mode=0700 // /where/to/mount

I open KDE Konsole, run this command, enter my password and the share is mounted successfully. Everything works just fine. So I thought a graphical prompt for my password would be nice. A bit of googling and I ended up with the following command:

MY_PASSWORD=$(kdialog --password "Give me your password")

The question is, how can I "feed" this password in $MY_PASSWORD to the sudo mount ...-command? In other words, how can I avoid having to type the password in Konsole after running sudo mount ... and instead automatically read it from said variable?

  • Have you read askubuntu.com/a/1269207? Maybe it's what you need. Nov 21 at 20:54
  • man sudo is a good starting point. In particular the options -A (--askpass) and -S (--stdin) may be of interest
    – roaima
    Nov 21 at 20:59

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.