I want to automate a command using SSH, but when it run appears a message to type yes or no. Its possible answer this message in one line command or someway in paramiko.
I've tried so many things like.
sudo /usr/sbin/service-maintenance-window ; yes
sudo /usr/sbin/service-maintenance-window | yes
yes | sudo /usr/sbin/service-maintenance-window
yes | sudo /usr/sbin/service-maintenance-window
Here is the code:
from paramiko import SSHClient
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("xxxx", username="xxxx", password="xxxx",timeout=5)
stdin,stdout,stderr = ssh.exec_command("yes | sudo /usr/sbin/service-maintenance-window")
print(stdout.read())
The message that i Want to accept is:
------------------------------ WARNING ---------------------------------------
You are about to be granted temporary privileged shell access of VPLEX
to perform advanced maintenance or servicing tasks.
As this shell has higher privileges, non-expert usage of this shell can
result in damage to your VPLEX as well as compromising of various
security features.
Respond Yes only if you are authorized and qualified to perform advanced
VPlex maintenance and/or servicing.
Make sure to:
1 - limit your use of this shell to only those items
that require this level of elevated privilege.
2 - exit this elevated privilege shell when you have finished using it.
-------------------------------------------------------------------------------
Are you sure you want to continue ? [Yes/No]: