【发布时间】:2020-03-16 14:58:49
【问题描述】:
我想使用 python 将文件从笔记本电脑保存到远程服务器,但出现错误: 操作系统错误:失败 从倒数第二个命令开始。
import paramiko
ssh_client =paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname='ipaddress',username='user',password='passwd', port='port')
ftp_client=ssh_client.open_sftp()
ftp_client.put('laptop/path/to/file/','server/saving/path/')
ftp_client.close()
此外,由于该文件上已存在同名文件,因此我想将其替换为该文件。任何想法为什么此代码不起作用?
我不想在我的终端上使用 ssh,因为我希望 python 脚本每周在文件更新时自动执行此操作。
提前谢谢你
【问题讨论】:
-
请提供完整的错误信息。
-
OSError: Failure 这只是错误消息。但我解决了这个问题。非常感谢! @AMC