I login our company server by ssh, but the server ask my password and otp token. Since i know my otp secret, so i can generate my otp in my script.
the prompt looks like this:
$ ssh mike@relay.office.com
Your password:
Your token:
let's assume my password is "123", and token is "456" I wrote a expect script like this, which is supposed to work
#!/usr/bin/expect
spawn ssh mike@relay.office.com
expect "password:"
send "123\n"
send "456\n"
interact
However the prompt just like this:
$ ./expect.sh
Your [EMAIL] password:
Your [VPN] token:
^[[?65;1;9cInvalid credentials
You see, the ssh server return some massy code followed by "Invalid credentials"
I don't understand where the messy code came from.
In normal situation. Even i type the wrong password or token, it will just prompt "Invalid credentials" without any messy code. Is it some sort of anti-script login
method from our ssh server?
Some Supplyment
Per answer below, i need to clarify, i forget to paste expect
line in my script before. But even with it, the problem stands still.
And another thing i didn't mention before, but maybe related. when i type ssh mike@xxx.com
. the server returned a QR code.(yeah, QR code in terminal.) it contains color escape
as well as some unicode characters
. I'm not sure if expect
has any bug on handling unicode characters