Paramiko “Unknown Server”

前端 未结 5 2165
余生分开走
余生分开走 2020-11-22 15:13

I\'m trying to get started with the Paramiko library, but the library is throwing an exception as soon as I try to connect with the following simple program:



        
5条回答
  •  迷失自我
    2020-11-22 16:03

    The exception was raised because you are missing a host key, the rather cryptic "Unknown server" is the clue - since the exception was raised from missing_host_key

    Try this instead:

    import paramiko
    
    paramiko.util.log_to_file('ssh.log') # sets up logging
    
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.connect('127.0.0.1', username=username, password=password)
    stdin, stdout, stderr = client.exec_command('ls -l')
    

提交回复
热议问题