2022-9-15 myluzh
Python
0x01 连接到linux ssh并执行命令
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)
0x02 连接到windows ssh并执行命令
因为windows的ssh是gbk所以有点麻烦,参考链接:paramiko连接windows10详解,远程管理windows服...
阅读全文>>
标签: python windows paramiko ssh
评论(0)
(580)