发布时间: 2022-9-15 文章作者: myluzh 分类名称: Python 朗读文章
import paramiko try: client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect('10.1.123.218', 22, username='admin', password='1234123', timeout=5) # print("连接成功") except: logger.info("连接ssh超时") exit() command = "whoami" stdin, stdout, stderr = client.exec_command(command) for std in stdout.readlines(): print(std)
import paramiko try: client = paramiko.SSHClient() client.load_system_host_keys() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect('10.6.10.19', 22, username='administrator', password='Aa123..', timeout=5) # print("连接成功") except: logger.info("连接ssh超时") exit() command = "whoami" stdin, stdout, stderr = client.exec_command(command) info = stdout.read().decode('gbk') + stderr.read().decode('gbk') print(info)
标签: python windows paramiko ssh
发表评论