7
Hello,
I am mounting a script where the user will authenticate on a device, if everything goes well the code continues otherwise it shows an error message. I am using the Paramiko library to do the session with the equipment, the connection is ok and it returns the message I want when the connection fails, but another error appears soon after.
MY CODE:
username = raw_input("Username:")
password = getpass.getpass("Password: ")
remote_conn_pre = paramiko.SSHClient()
remote_conn_pre.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
remote_conn_pre.connect('1.111.111.111', username=username, password=password)
except paramiko.ssh_exception.AuthenticationException:
print ("Erro de login.")
ERROR NEXT:
File "run.py", line 67, in <module>
remote_conn_pre.connect(ip, username=username, password=password)
File "C:\Python27\lib\site-packages\paramiko\client.py", line 380, in connect
look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
File "C:\Python27\lib\site-packages\paramiko\client.py", line 603, in _auth
raise saved_exception
paramiko.ssh_exception.AuthenticationException: Authentication failed.
I don’t think I know how to use the paramiko.ssh_exception.AuthenticationException right, someone can help me?
And one more question, There is how I do if it gives error, it return to the user to enter the username/ password again?
I’m sorry, I’m kind of new to programming and Python, so I was wondering. Thank you very much!
already tried only except without the
paramiko.ssh_exception.AuthenticationException
?– ederwander