##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()