I have Linux remote machine that running a script on the login attempt, which it will run the script, and its require the user input.
The main intention is to test the login user, the password with the auto-scripts response remotely when logon to that user.
Information inside the remote machine:
$ cat /etc/passwd
remoteuser:dontcare:dontcare:dontcare:dontcare:/usr/bin/somescript.sh
When user login into remoteuser, the somescript.sh will run.
The content of the script which asking for the user input
$ read -p '>' tmp
and I don't want to do any changes to that script.
Example of login
login: remoteuser
Password: remoteuserpassword
Quit Configuration (q, quit)
Is it possible for me to send the user input using ssh command? Currently my approach is using paramiko ssh,
connection = paramiko.SSHClient() using exec_command
but still it failed to send the input in right sequence or failed to passed to that script.
$ echo q
to the paramiko exec connection.exec_command('echo q')
I not using login as from root to test this remote user because it doesn't ask for password.
echo q | su - remoteuser