Since you are actually trying to use the ssh program, the EXOS shell is getting in the way.
My suggestion is to invoke ssh directly and just use pexpect.
The challenge with this method is how to determine the VR number for ssh.
E.g. VR-Mgmt = 0, VR-Default=2
Try running the CLI command:
run script cli2json.py -d show virtual-router
Then look for "vrId":
when name2 is VR-OAM
the vrId is the number for -r below
import pexpect
p = pexpect.spawn('/exos/bin/ssh -r 2 root@192.168.140.190')
idx = p.expect(['password', pexpect.EOF, pexpect.TIMEOUT])
p.sendline('mysecretpassword')
.
.
.
p.sendline('exit')