My access to ssh is limited by the Google Authenticator authentication code hint. I would like to have a script that programmatically responds to this prompt.
Context
- The variable ($ 1) is correctly passed to the script - this is the confirmation code.
- The sshfs command works in the terminal.
- A
Verification code:space appears on the command line and a key symbol at the end.
[EDIT] To make sure we don’t get into the security discussion here, please note that, of course, I also use SSH keys, as well as this Google Authenticator . Since the authentication code expires every x seconds , it does not matter that others can intercept it.
Result
The drive is mounted (I see it with df -h), but it's empty ... Does it look the same behavior as with the wrong Verification code, or maybe it does not have time to execute?
Shell script :
expect_sh=$(expect -c "
spawn /usr/local/bin/sshfs username@123.123.1.123:/path/to/folder/RAID1 /Users/username/Desktop/RAID1 -o defer_permissions -o volname=RAID1
expect \"Verification code:\"
send \"$1\r\";
")
echo "$expect_sh"
thank
user6198643
source
share