I’m trying to clone from my private git repository using expect to enter the password in one line.
I’m trying something like:
expect -c ‘spawn git clone user@..*.*:/var/…/repository.git/; expect “(yes/no)?”; send “yes\n”; expect “password:”; send “my_password\n”;interact’
But, it doesn’t work.
What am I doing wrong? How can I fix the command line above?
Thanks, Arshavdki Alexander
Why don’t you just use something more secure than a password and simplify your life?
An ssh key with no password will be significantly more secure and not prompt at all.
If it must be 100% self-contained, then consider making the script output the SSH key, use it once, then remove it. (That should leave your security situation unchanged: the password is effectively in the script, which is acceptable for you.)
Yes the script looks unwieldy but (modulo bugs) it is self-contained pretty useful for automation.