I encountered a problem connecting to the server. I'm in this topic for the first time, so I don't understand why I can't connect, it seems that I entered all the data. I Googled and realized that I needed a key, then I got the key in puttygen. But it didn't help.
code:
import pysftp
from base64 import decodebytes
import paramiko
# cnopts = pysftp.CnOpts()
# cnopts.hostkeys = None
cnopts = pysftp.CnOpts(knownhosts='ssh-rsa 2048 SHA256:PEFk7nDBYtqlmNC4VIA8qSx/ii2Gn9T5NuVKHRLM72s')
srv = pysftp.Connection(host="193.34.144.226", username="root", password="**********", cnopts = cnopts)
data = srv.listdir()
srv.close()
for i in data:
print(i)
traceback:
C:\Users\futgi\AppData\Local\Programs\Python\Python39\lib\site-packages\pysftp\__init__.py:61: UserWarning: Failed to load HostKeys from 193.34.144.226 ssh-rsa 2048 SHA256:PEFk7nDBYtqlmNC4VIA8qSx/ii2Gn9T5NuVKHRLM72s. You will need to explicitly load HostKeys (cnopts.hostkeys.load(filename)) or disableHostKey checking (cnopts.hostkeys = None).
warnings.warn(wmsg, UserWarning)
Traceback (most recent call last):
File "D:\python\FREELANCE\qa_parser\answers_parser\server_requests.py", line 11, in
srv = pysftp.Connection(host="193.34.144.226", username="root", password="*********", cnopts = cnopts)
File "C:\Users\futgi\AppData\Local\Programs\Python\Python39\lib\site-packages\pysftp\__init__.py", line 132, in __init__
self._tconnect['hostkey'] = self._cnopts.get_hostkey(host)
File "C:\Users\futgi\AppData\Local\Programs\Python\Python39\lib\site-packages\pysftp\__init__.py", line 71, in get_hostkey
raise SSHException("No hostkey for host %s found." % host)
paramiko.ssh_exception.SSHException: No hostkey for host 193.34.144.226 found.
Exception ignored in:
Traceback (most recent call last):
File "C:\Users\futgi\AppData\Local\Programs\Python\Python39\lib\site-packages\pysftp\__init__.py", line 1013, in __del__
self.close()
File "C:\Users\futgi\AppData\Local\Programs\Python\Python39\lib\site-packages\pysftp\__init__.py", line 784, in close
if self._sftp_live:
AttributeError: 'Connection' object has no attribute '_sftp_live'