Paramiko身份验证失败?

时间:2017-04-11 23:47:19

标签: python

我试图解决它,但每次都得到同样的错误。我曾多次尝试过谷歌,但无法给出合适的答案。

def ssh(hostname, command):

   sshcon = paramiko.SSHClient()

   logging.basicConfig()

   sshcon.load_system_host_keys()

   sshcon.set_missing_host_key_policy(paramiko.AutoAddPolicy())

   sshcon.connect(hostname, username='root', password='password')

   stdin, stdout, stderr = sshcon.exec_command(command)

   return stdout.read()

while True:

    i = 1
    while i <= 60:
        print "|------- Webserver2 -----------|"
        print time.ctime()
        response_time(desired_response_time, url2, webserver2, bilal2, local)
        list=ssh(bilal2, "xm list")
        if "webserver1" in list:
           horizontal('2')
           print "|------- Webserver1 -----------|"
           response_time(desired_response_time, url1, webserver1, bilal2, local)
        else:
             horizontal('1')
             pass
        time.sleep(5)
        i += 1

错误

Error:
Traceback (most recent call last):
  File "newcodepid.py", line 472, in <module>
    list=ssh(bilal2, "xm list")
  File "newcodepid.py", line 61, in ssh
    sshcon.connect(hostname, username='root', password='password') 
  File "/usr/lib/python2.7/dist-packages/paramiko/client.py", line 332, in connect
    self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys)
  File "/usr/lib/python2.7/dist-packages/paramiko/client.py", line 493, in _auth
    raise saved_exception
paramiko.AuthenticationException: Authentication failed.

0 个答案:

没有答案