##CE12800 交换机上配置
sftp server enable
user-interface vty 0 4
authentication-mode aaa
protocol inbound ssh[*SSH Server] aaa
[*SSH Server-aaa] local-user adminadmin password irreversible-cipher Huawei@123
[*SSH Server-aaa] local-user adminadmin level 3
[*SSH Server-aaa] local-user adminadmin service-type ssh
[*SSH Server-aaa] quitssh user adminadmin
ssh user adminadmin authentication-type password
ssh user adminadmin service-type stelnet sftp ssh //按需要开启配置
ssh user adminadmin sftp-directory cfcard:/
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()