2 Replies Latest reply: Feb 26, 2014 7:43 AM by ussuriysk
ussuriysk Level 1 Level 1 (0 points)

I'm trying to use putty/plink to login to my mac (from a w7 pc) and use hdiutil to mount an encrypted dmg. I've tried several ways:

          plink -ssh user@server hdiutil attach -stdinpass file.dmg

                    I get prompted for the login password but when I enter it and press return there is no response. No further prompt for the dmg password.

          putty -ssh user@server -m textfile

          (where text file contains either the hdiutil command above, or names a shell script on the mac containing the command)

                    In this case I get prompted for the login password and it's accepted, but then the cmd window doesn't accept any further input.

                    I know that the login password is being accepted because I can echo some text before hdiutil command in the script.

 

Oddly, it's happy to DETACH a mounted dmg.

          plink -ssh user@server hdiutil detach /Volumes/mounteddmg

                    takes the login password and ejects the volume on the mac. Works every time.

 

I keep thinking that the problem lies in hdiutil's -stdinpass argument, perhaps it's not seeing the incoming putty/plink connection as stdin?


iMac, OS X Mavericks (10.9.2)
  • Linc Davis Level 10 Level 10 (168,915 points)
    plink -ssh user@server 'printf password | hdiutil attach -stdinpass file.dmg'
    
  • ussuriysk Level 1 Level 1 (0 points)

    That does work!  However it does mean that the password is in clear text in a file on the desktop. 

     

    I got it to prompt the user for the password:

     

    plink -ssh user@server "echo 'Enter dmg password: '; read -s -n 14 pass; printf $pass | hdiutil attach -stdinpass file.dmg"

     

    I couldn't figure out how to get the shell to take the password terminated with the return key, it always wants ctrl-z so I just had it read the length of the password

     

    Thanks so much!