无聊的IT

导航

python调用 sshpass

[root@qinhan ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.43.105  netmask 255.255.255.0  broadcast 172.16.43.255
        inet6 fe80::20c:29ff:fe22:1f4f  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:22:1f:4f  txqueuelen 1000  (Ethernet)
        RX packets 2  bytes 120 (120.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 768 (768.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eno33554984: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.27.100  netmask 255.255.255.0  broadcast 192.168.27.255
        inet6 fe80::20c:29ff:fe22:1f59  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:22:1f:59  txqueuelen 1000  (Ethernet)
        RX packets 13415  bytes 9012322 (8.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8337  bytes 1137911 (1.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 1301  bytes 132447 (129.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1301  bytes 132447 (129.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@qinhan ~]# python
Python 3.6.2 (default, Jan 10 2018, 16:15:47) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.run('sshpass -p root ssh root@192.168.27.3 -o "StrictHostKeyChecking no"',shell=True)
Last login: Fri Jan 19 10:42:16 2018 from node2.magedu.com
[root@node1 ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.43.102  netmask 255.255.255.0  broadcast 172.16.43.255
        inet6 fe80::20c:29ff:fe53:14fc  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:53:14:fc  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 768 (768.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eno33554960: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.27.3  netmask 255.255.255.0  broadcast 192.168.27.255
        inet6 fe80::20c:29ff:fe53:1406  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:53:14:06  txqueuelen 1000  (Ethernet)
        RX packets 1898  bytes 198151 (193.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 785  bytes 175186 (171.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 3588  bytes 310356 (303.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3588  bytes 310356 (303.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@node1 ~]# 

 

posted on 2018-01-19 10:53  秦寒  阅读(611)  评论(0编辑  收藏  举报