Answer the question
In order to leave comments, you need to log in
How to fix pysftp connection error?
Hello. Faced a problem connecting to the server. I’m generally in this thread for the first time, so I don’t understand why I can’t connect, it seems that I entered all the data. Google realized that you need to get the key, got the key in putigen. But absolutely nothing.
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)
Answer the question
In order to leave comments, you need to log in
Port not specified:
...
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None # disable host key checking.
# Connection to external SFTP server
with pysftp.Connection(host=SFTP_HOST,
port=SFTP_PORT,
username=SFTP_USER,
password=fernet_decrypt(fernet_key=SFTP_KEY, encoded=SFTP_PASS_ENC),
cnopts=cnopts,
) as sftp:
# Change external directory
with sftp.cd(EXTERNAL_DIR):
external_dir = sftp.listdir()
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question