I'm trying to do something really simply (I think) with pexpect but must
be missing an obvious step.  I want to ssh from host to guest, establish
a CIFS connection on the guest to a share somewhere else on the local
network, open a luks loop device on the share by entering the password
(I don't want this to be non-interactive, either with a key file or by
including the password in the pexpect script) and then mounting the device.

I'm using the following code:

password = getpass.getpass('Enter passphrase for /opt/luks: ')
child = pexpect.spawn('ssh root@192.168.56.101')
child.interact()
child.sendline('mount.cifs -o credentials=/root/cred_f //192.168.56.1/f
/opt')
child.sendline('losetup /dev/loop0 /opt/luks')
child.sendline('cryptsetup luksOpen /dev/loop0 l')
child.expect('Enter passphrase for /opt/luks: ')
child.sendline(password)
child.sendline('mount /dev/mapper/l /opt')
child.sendline('exit')

The best that happens is the CIFS share gets mounted and the program
exits while leaving me in the child terminal.  I've tried varying the
placement of child.interact() but that makes no difference or replacing
the first line which uses getpass with a 'child.expect' line when the
password is required.

Could anyone help me?
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to