Menu

Sending Password Over SSH via Shell Script

2018-12-23
2019-01-05
  • Andrew Claus

    Andrew Claus - 2018-12-23

    Hello I am trying to mount a volume on a Linux machine over ssh. I can do it once SSH'd into the machine with no user prompts with

    veracrypt /mnt/data/name.hc /mnt/name --password='password' --pim=### --protect-hidden=no --keyfiles=''
    

    When I run the command via shell SSH, it fails

    ssh -t pi@$IP -i "$PEM" "veracrypt /mnt/data/name.hc /mnt/name --password='password' --pim=### --protect-hidden=no --keyfiles=''"
    

    yields

    Operation failed due to one or more of the following:
     - Incorrect password.
     - Incorrect Volume PIM number.
     - Incorrect PRF (hash).
     - Not a valid volume.
    

    I then can enter the password when prompted and it works.

     

    Last edit: Andrew Claus 2018-12-23
  • Adrian Kentleton

    Have you tried not enclosing the veracrypt command and parameters in double quotes when using SSH? Would not be necessary if mounting a VC volume via SSH on a Windows PC.

     
    • Andrew Claus

      Andrew Claus - 2018-12-23

      Then it fails on my password whether I double or single quote it. I do have special characters in the password

       
      • Andrew Claus

        Andrew Claus - 2018-12-23

        Hmmmmm it may be the special characters. My password started with & and after some changes it seems that breaks out of the quotes when passing a command to SSH. Enter te&st and it will say "st: command not found"

         
  • Adrian Kentleton

    The ampersand is the problem. You should never use them in passwords you intend to invoke using the command line. In Windows, wherever it occurs, it will always be interpreted as an end marker for the current command, and an instruction to interpret everything that follows as a new command. In Linux, it has a slightly different meaning (I think Linux '&&' is equivalent to Windows '&') viz 'continue to run the current command in the background' ie where 'current' means everything up to the ampersand ie the effect is the same as in Windows.

    There have been a number of discussions of this issue in the forum (though none recently, so they'd be a bit hard to track down).

     
    👍
    1
    • Andrew Claus

      Andrew Claus - 2018-12-31

      Thanks Adrian. That makes sense.

       
      • Andrew Claus

        Andrew Claus - 2019-01-05

        For other people who encounter this, I have thus far learned you cannot pass & or $. Both make sense, but threw me off

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.