N
N
Nikolay Baranenko2017-04-04 03:37:21
Python
Nikolay Baranenko, 2017-04-04 03:37:21

Why is Server %r not found in known_hosts' % hostname returned when the server is available via telnet on ssh port 22?

Hello.
I'm trying to create a client for Linux in python 3.6.1 x64 using the paramiko package.
Running the following code

import paramiko

ssh = paramiko.SSHClient()
HOSTNAME="192.168.0.27"
USERNAME="user1"
PASSWORD="pwd"
ssh.connect(HOSTNAME, username=USERNAME, password=PASSWORD)
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command("ps ax | grep 'user1'")

I receive in response
C:\Python36\python.exe C:/Server/repositories/templates/Test/SSH.py
Traceback (most recent call last):
  File "C:/Server/repositories/templates/Test/SSH.py", line 37, in <module>
    ssh.connect(HOSTNAME, username=USERNAME, password=PASSWORD)
  File "C:\Python36\lib\site-packages\paramiko\client.py", line 362, in connect
    server_key)
  File "C:\Python36\lib\site-packages\paramiko\client.py", line 673, in missing_host_key
    raise SSHException('Server %r not found in known_hosts' % hostname)
paramiko.ssh_exception.SSHException: Server '192.168.0.27' not found in known_hosts

although SSH on server port 22 192.168.0.27 is available.
How to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2017-04-04
@res2001

Key phrase: "not found in known_hosts". Those. not found in the list of known hosts.
Your client received a key from the server, but the key is not in the list of known hosts.
Usually, interactive clients ask the user something like "Unknown server, add it to the known list?" in this case. In your case, this is done somehow programmatically or by package settings. Smoke the manual in this direction.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question