You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently this is what is do in Putty on windows on daily basis.
Click on my host then it prompts me like this, yes it has two level authentication
login as: loginName(Then enter)
Password: Password1(Then enter)
Username: UserName(Then enter)
Password: Password2(Then enter)
Then one more Enter
Here I get my Required output shown on Putty , this is just a couple line of text which usually gets changed everyday.
So i need to capture this on a daily basis.
I am not sure is this the right way to write my code.
I am sure it gets connected to hostname on level 1, but second level username is not passed. So not sure what I am doing wrong.
import traceback
import paramiko
from paramiko_expect import SSHClientInteraction
client = paramiko.SSHClient()
# Set SSH key parameters to auto accept unknown hosts
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
hostname = 'MyCustomServer.com'
login = 'myFirstLevelLogin'
password1 = 'MyFirstPassword'
username = 'mySecondLevelLogin'
password2 = 'MySecondPassword'
prompt1 = 'Username:'
prompt2 = 'Password:'
# Connect to the host
client.connect(hostname=hostname, username=login, password=password1)
# Create a client interaction class which will interact with the host
interact = SSHClientInteraction(client, timeout=10, display=True)
interact.expect(prompt1)
interact.send('username')
interact.expect(prompt2)
interact.send(password2)
interact.expect('Not sure what to put here as i just press enter in my usual putty session ')
interact.send('I send enter key')
interact.expect('This is my final output its two lines of text no command prompt here(i mean the typical user@mymachine:$) this will not be found, this screen goes off after 5 seconds')
cmd_output = interact.current_output_clean
# Send the exit command and expect EOF (a closed session)
interact.send('exit')
interact.expect()
print (cmd_output)
Thank you for this wonderful package
The text was updated successfully, but these errors were encountered:
Currently this is what is do in Putty on windows on daily basis.
Click on my host then it prompts me like this, yes it has two level authentication
I am not sure is this the right way to write my code.
I am sure it gets connected to hostname on level 1, but second level username is not passed. So not sure what I am doing wrong.
Thank you for this wonderful package
The text was updated successfully, but these errors were encountered: