paramiko put方法调用时提示IOError: [Errno 2] No such file的几种可能

class sftp_operation:
    def __init__(self, host,port,username,password):
        self.host=host
        self.port=port
        self.username=username
        self.password=password
        transport = paramiko.Transport((self.host, self.port))
        transport.connect(username=self.username, password=self.password)
        self.sftp = paramiko.SFTPClient.from_transport(transport)

    def close(self):
        self.sftp.close()


调用:

    sftp=sftp_operation(args_param['host'],args_param['port'],args_param['username'],args_param['password'])

        sftp.sftp.put(os.path.join(local_path, f), os.path.join(remote_code_path,f))

 

 

可能一、

本地文件或者远程目录存在权限问题,检查权限

 

可能二、

本地文件或者远程目录用了“~/xxxx/xxxx”,注意paramiko无法将~识别为个人的home目录,所以会提示找不到

posted on 2022-09-09 17:46  该用户很懒  阅读(543)  评论(0编辑  收藏  举报