本文主要是介绍华为ce12800文件保存python之sftp,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
##CE12800 交换机上配置
[*SSH Server] dsa local-key-pair create
[*SSH Server] sftp server enable
[*SSH Server] ssh user adminadmin authentication-type password
[*SSH Server] ssh user adminadmin service-type sftp
[*SSH Server] ssh user adminadmin sftp-directory cfcard:/
[*SSH Server] aaa
[*SSH Server-aaa] local-user adminadmin password irreversible-cipher Helloworld@6789
[*SSH Server-aaa] local-user adminadmin level 15
[*SSH Server-aaa] local-user adminadmin service-type ssh
[*SSH Server-aaa] quit
python服务端配置
import paramiko,time
client = paramiko.client.SSHClient()
client.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
client.connect(hostname=‘10.1.1.100’,port=22, username=‘adminadmin’, password=‘Huawei@123’)
time.sleep(2)
sftp = client.open_sftp()
time.sleep(2)
local_path = r"D:\temp\back.cfg" #必须写具体的要保存的文件名,不能写上一级文件夹名
remote_path = r’/test.cfg’
sftp.get(remote_path, local_path) #下载
#sftp.put(local_path,’ /test.cfg’) #上传
time.sleep(2)
client.close()
这篇关于华为ce12800文件保存python之sftp的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!