Search code examples
passwordscygwinexpectpsftp

Expect echo password in clear text


Automating psftp with bash/expect in cygwin.

I have a very minimal script file yftp.exp with code:

#!/usr/bin/expect -f
spawn psftp unixftpsrvr
expect "login as: "
send "myID\r"
expect "Password:"
send "Passw0rd\r"
expect "psftp>"

the output:

$ ./yftp.exp
spawn psftp unixftpsrvr
login as: myID
Using keyboard-interactive authentication.
Enter your UDS
Password: Passw0rd

Remote working directory is /home/myID
psftp>

The password is printed out as clear text!!!

if I run the command directly with psftp. here are the output:

$ psftp unixftpsrvr
login as: myID
Enter your UDS Password:
Remote working directory is /home/myID
psftp>

The password is not displayed at all.

This seems to be more an issue on the expect side.

I am not concerned the password in clear text in my expect script file, I am concerned the password in clear text in the output!

how can I supress the display of password in clear text?


Solution

  • The password may be sent too early before ECHO is turned off. So try adding sleep 1 after expect "Password:".

    If that does not work then try like this:

    expect "Password:"
    log_user 0; # disable logging to stdout
    send "password\r"
    log_user 1