In a shell script, I need to automatically fill the passphrase when running ssh-add
.
I came across expect
and tried this script, but with no luck:
expect -c "spawn ssh-add; expect -re \".*passphrase.*\"; send \"mypass\r\n\";"
The script doesn't throw any errors, but when it ssh it asks for password (meaning it didn't work).
EDIT: If run ssh-add
and add the passphrase manually it works as expected.