Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1836  / 3 Years ago, mon, may 24, 2021, 10:43:34

I am trying to make a script that will mount an encrypted volume (dm-crypt / luks) with a password that is passed as argument to that script.



My trouble is that I can't find a way to make that script work ...



For instance, when I run this :



mount /my/encrypted/path > file.txt 2>&1


it still shows me the password question outside the script and let me type the password .... It's just like the mount command found a way to escape the redirections that I've set ....



So it's impossible for me now to input a password due to the fact that the part that ask me the password runs outside my script .....



How mount found a way to escape redirection ? I don't know.



Do I have to change some configuration file ? I don't know.



Is mount has some luks specific commands ? I don't know.



How can I mount an encrypted volume via a script without having "human" interaction with my script (aka : my script type the password) ?



I know that what I try to achieve may represent a security risk .... but the password will be transferred in a secure way to the script (so do not care about the potential security risk that it can involve).



In case this matters : I try to achieve this under Ubuntu 64bit 11.10.


More From » 11.10

 Answers
6

I've finally found the answer in another website.



In order to script a password process with mount you can do it by redirecting to stdin the password.



In order to do that you must specify to mount that you want to use stdin for the password witch is the option "-p 0"



The script for auto mounting an encrypted volume is like this :



mount /your/encrypted/path -p 0 <<EOF
The password
EOF


This is one of the existing methods in order to write to stdin. This one is not quite secure but the simplest way to do it in order to show the concept.



Best regards.


[#38472] Wednesday, May 26, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
urnaetted

Total Points: 10
Total Questions: 113
Total Answers: 117

Location: Burundi
Member since Sat, Aug 21, 2021
3 Years ago
;