Opening encrypted volumes using a script [closed]












1














I have two encrypted volumes that I use occasionally. One is a partition and the other is a container file. I always use them at the same time.



I currently open them using something like this:



$ sudo cryptsetup -y open --type plain /dev/sda4 v1
$ sudo mount -t ext4 /dev/mapper/v1 /mnt/v1
$ sudo losetup /dev/loop0 v2
$ sudo cryptsetup open --type luks /dev/loop0 v2
$ sudo mount -t ext4 /dev/mapper/v2 /mnt/v2


But it's laborious entering these commands every time, even if I use history expansion.



If I put the commands in a script, is it possible to get the script to ask me to enter the passphrase for each volume?










share|improve this question















closed as off-topic by terdon Dec 16 at 16:17


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – terdon

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Have you tried? Because that's exactly what it'll do...
    – Fabby
    Dec 16 at 11:40
















1














I have two encrypted volumes that I use occasionally. One is a partition and the other is a container file. I always use them at the same time.



I currently open them using something like this:



$ sudo cryptsetup -y open --type plain /dev/sda4 v1
$ sudo mount -t ext4 /dev/mapper/v1 /mnt/v1
$ sudo losetup /dev/loop0 v2
$ sudo cryptsetup open --type luks /dev/loop0 v2
$ sudo mount -t ext4 /dev/mapper/v2 /mnt/v2


But it's laborious entering these commands every time, even if I use history expansion.



If I put the commands in a script, is it possible to get the script to ask me to enter the passphrase for each volume?










share|improve this question















closed as off-topic by terdon Dec 16 at 16:17


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – terdon

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Have you tried? Because that's exactly what it'll do...
    – Fabby
    Dec 16 at 11:40














1












1








1







I have two encrypted volumes that I use occasionally. One is a partition and the other is a container file. I always use them at the same time.



I currently open them using something like this:



$ sudo cryptsetup -y open --type plain /dev/sda4 v1
$ sudo mount -t ext4 /dev/mapper/v1 /mnt/v1
$ sudo losetup /dev/loop0 v2
$ sudo cryptsetup open --type luks /dev/loop0 v2
$ sudo mount -t ext4 /dev/mapper/v2 /mnt/v2


But it's laborious entering these commands every time, even if I use history expansion.



If I put the commands in a script, is it possible to get the script to ask me to enter the passphrase for each volume?










share|improve this question















I have two encrypted volumes that I use occasionally. One is a partition and the other is a container file. I always use them at the same time.



I currently open them using something like this:



$ sudo cryptsetup -y open --type plain /dev/sda4 v1
$ sudo mount -t ext4 /dev/mapper/v1 /mnt/v1
$ sudo losetup /dev/loop0 v2
$ sudo cryptsetup open --type luks /dev/loop0 v2
$ sudo mount -t ext4 /dev/mapper/v2 /mnt/v2


But it's laborious entering these commands every time, even if I use history expansion.



If I put the commands in a script, is it possible to get the script to ask me to enter the passphrase for each volume?







shell-script cryptsetup






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 16 at 10:28









Vlastimil

7,6911260133




7,6911260133










asked Dec 16 at 10:26









EmmaV

1,1091331




1,1091331




closed as off-topic by terdon Dec 16 at 16:17


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – terdon

If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by terdon Dec 16 at 16:17


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – terdon

If this question can be reworded to fit the rules in the help center, please edit the question.












  • Have you tried? Because that's exactly what it'll do...
    – Fabby
    Dec 16 at 11:40


















  • Have you tried? Because that's exactly what it'll do...
    – Fabby
    Dec 16 at 11:40
















Have you tried? Because that's exactly what it'll do...
– Fabby
Dec 16 at 11:40




Have you tried? Because that's exactly what it'll do...
– Fabby
Dec 16 at 11:40










2 Answers
2






active

oldest

votes


















0














Silly me. I should have tested before asking.



I am asked for the passphrases when executing these commands in a script.






share|improve this answer





























    0














    read -sp ‘Enter passphrase ‘ pw
    echo “${pw}” | cryptsetup ...

    should do the trick






    share|improve this answer






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Silly me. I should have tested before asking.



      I am asked for the passphrases when executing these commands in a script.






      share|improve this answer


























        0














        Silly me. I should have tested before asking.



        I am asked for the passphrases when executing these commands in a script.






        share|improve this answer
























          0












          0








          0






          Silly me. I should have tested before asking.



          I am asked for the passphrases when executing these commands in a script.






          share|improve this answer












          Silly me. I should have tested before asking.



          I am asked for the passphrases when executing these commands in a script.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 16 at 14:51









          EmmaV

          1,1091331




          1,1091331

























              0














              read -sp ‘Enter passphrase ‘ pw
              echo “${pw}” | cryptsetup ...

              should do the trick






              share|improve this answer




























                0














                read -sp ‘Enter passphrase ‘ pw
                echo “${pw}” | cryptsetup ...

                should do the trick






                share|improve this answer


























                  0












                  0








                  0






                  read -sp ‘Enter passphrase ‘ pw
                  echo “${pw}” | cryptsetup ...

                  should do the trick






                  share|improve this answer














                  read -sp ‘Enter passphrase ‘ pw
                  echo “${pw}” | cryptsetup ...

                  should do the trick







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Dec 16 at 15:59









                  vfbsilva

                  2,62711227




                  2,62711227










                  answered Dec 16 at 15:01









                  jas-

                  71238




                  71238















                      Popular posts from this blog

                      Morgemoulin

                      Scott Moir

                      Souastre