Here is my code:
import pysftp
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
host = "192.168.8.104"
username = "pi"
password = "raspberry"
local_path = "C:\Users\helencecilia\Desktop\Basura\Conexion SFTP\download.txt"
remote_path = "\home\pi\helloworld.txt"
with pysftp.Connection(host, username, password, cnopts=cnopts) as sftp:
sftp.put(local_path, remote_path)
Error message:
C:\Python27\lib\site-packages\pysftp\__init__.py:61: UserWarning: Failed to load HostKeys from C:\Users\helencecilia\.ssh\known_hosts. 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 "C:\Users\helencecilia\Desktop\Basura\Conexion SFTP\prueba.py", line 12, in <module>
with pysftp.Connection(host, username, password, cnopts=cnopts) as sftp:
File "C:\Python27\lib\site-packages\pysftp\__init__.py", line 142, in __init__
self._set_authentication(password, private_key, private_key_pass)
File "C:\Python27\lib\site-packages\pysftp\__init__.py", line 167, in _set_authentication
private_key_file, private_key_pass)
File "C:\Python27\lib\site-packages\paramiko\pkey.py", line 196, in from_private_key_file
key = cls(filename=filename, password=password)
File "C:\Python27\lib\site-packages\paramiko\rsakey.py", line 45, in __init__
self._from_private_key_file(filename, password)
File "C:\Python27\lib\site-packages\paramiko\rsakey.py", line 163, in _from_private_key_file
data = self._read_private_key_file('RSA', filename, password)
File "C:\Python27\lib\site-packages\paramiko\pkey.py", line 267, in _read_private_key_file
with open(filename, 'r') as f:
IOError: [Errno 2] No such file or directory: 'raspberry'
- The ip address is correct
- The name and password is correct
- The ssh server is connected correctly and they are the same network
- Desk paths are correct and exist