模拟器里的IP 已经变动
import paramiko
import time
username = 'python'
password = '123asd'
iplist =['192.168.1.9', '192.168.1.10', '192.168.1.11']
for ip in iplist:
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname=ip, username=username, password=password, look_for_keys=False)
print('=-=-=-=-=-=-=-=-=-=-=-=-=-=')
print('已经成功登陆交换机 ' + ip)
command = ssh_client.invoke_shell()
command.send('ftp 192.168.1.8n')
time.sleep(0.5)
command.send('rootn')
time.sleep(0.5)
command.send('Lxf940709.n')
time.sleep(0.5)
command.send('binn')
command.send('put vrpcfg.zip '+ip +'_vrpcfg.zip'+'n')
time.sleep(0.5)
command.send('quitn')
time.sleep(0.5)
output = command.recv(65535).decode('GB2312')
print(output)
ssh_client.close()
C:Users82127.condaenvspythonProjectpython.exe E:/log/python/pythonProject/Demo06.py
=-=-=-=-=-=-=-=-=-=-=-=-=-=
已经成功登陆交换机 192.168.1.9
Info: The max number of VTY users is 5, and the number
of current VTY users on line is 1.
The current login time is 2022-06-01 23:34:42.
ftp 192.168.1.8
Trying 192.168.1.8 ...
Press CTRL+K to abort
Connected to 192.168.1.8.
220 (vsFTPd 3.0.3)
User(192.168.1.8:(none)):root
331 Please specify the password.
Enter password:
230 Login successful.
[ftp]bin
200 Switching to Binary mode.
[ftp]put vrpcfg.zip 192.168.1.9_vrpcfg.zip
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
FTP: 602 byte(s) sent in 0.170 second(s) 3.54Kbyte(s)/sec.
[ftp]quit
221 Goodbye.
=-=-=-=-=-=-=-=-=-=-=-=-=-=
已经成功登陆交换机 192.168.1.10
Info: The max number of VTY users is 5, and the number
of current VTY users on line is 1.
The current login time is 2022-06-01 23:34:45.
ftp 192.168.1.8
Trying 192.168.1.8 ...
Press CTRL+K to abort
Connected to 192.168.1.8.
220 (vsFTPd 3.0.3)
User(192.168.1.8:(none)):root
331 Please specify the password.
Enter password:
230 Login successful.
[ftp]bin
200 Switching to Binary mode.
[ftp]put vrpcfg.zip 192.168.1.10_vrpcfg.zip
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
FTP: 603 byte(s) sent in 0.160 second(s) 3.76Kbyte(s)/sec.
[ftp]quit
221 Goodbye.
=-=-=-=-=-=-=-=-=-=-=-=-=-=
已经成功登陆交换机 192.168.1.11
Info: The max number of VTY users is 5, and the number
of current VTY users on line is 1.
The current login time is 2022-06-01 23:34:48.
ftp 192.168.1.8
Trying 192.168.1.8 ...
Press CTRL+K to abort
Connected to 192.168.1.8.
220 (vsFTPd 3.0.3)
User(192.168.1.8:(none)):root
331 Please specify the password.
Enter password:
230 Login successful.
[ftp]bin
200 Switching to Binary mode.
[ftp]put vrpcfg.zip 192.168.1.11_vrpcfg.zip
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
FTP: 603 byte(s) sent in 0.190 second(s) 3.17Kbyte(s)/sec.
[ftp]quit
221 Goodbye.
进程已结束,退出代码0
[root@testhost ~]# ll total 20 -rw-r--r-- 1 root root 603 Jun 2 07:34 192.168.1.10_vrpcfg.zip -rw-r--r-- 1 root root 603 Jun 2 07:34 192.168.1.11_vrpcfg.zip -rw-r--r-- 1 root root 602 Jun 2 07:34 192.168.1.9_vrpcfg.zip



