I am trying to automate the deployment of a linux server using python and paramiko. The problem is that the first time I connect to this custom Linux OS it ask for parameters for it's initial "installer".
You cannot do anything with the server until these parameters are set. The first parameter is to set a new password and you are prompted from the terminal like shown below.
*WARNING: Your password has expired.
You must change your password now and login again!
New password:
I can't figure out how to just send basic user input such as a new password. From my understanding the exec_command is actually expecting linux commands not just a string of characters to pass to the terminal.
How can I simply connect up and send a raw string to the terminal to do this?
This is what I've tried, but doesn't work:
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('my_host', username='admin', key_filename='My path to private key file')
stdin, stdout, stderr = ssh.exec_command('sleep 10')
stdin.write('NewPassword')
stdin.write('NewPassword')
ssh.close()