How to script SFTP two-factor authentication?

1

I need to script file transfers between two servers. Local server is RHEL 5.x. Remote location uses two-factor authentication (key+password). Authenticates fine on the key-pair but I can't find syntax that would allow me to relay the password.

Command example that partialy works:

sftp -oIdentityFile=<path_to_ssh_key> <un>@<site>

SCP is apparently a possibility, but the remote location apparently doesn't have anyone who uses it so future support might be shallow.

Anything else I can try?

Confused

Posted 2013-01-10T19:57:23.990

Reputation: 11

Have you looked into expect before? You can basically set it up to watch for a specific return, and then send the password. Since it integrates well into scripts, you could store the password in an encrypted file and decrypt only when needed (using GPG)

– nerdwaller – 2013-01-10T20:12:24.627

No answers