paramiko免密登陆
# -*- coding: utf-8 -*-
import paramiko
pkey='D:/pycharm_workspace/testpy/ssh_paramiko_demo/id_rsa'
key=paramiko.RSAKey.from_private_key_file(pkey)
paramiko.util.log_to_file('paramiko.log')
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# ssh.load_system_host_keys()
ssh.connect('192.168.*.*',username = 'root',pkey=key)
stdin,stdout,stderr=ssh.exec_command('hostname')
print(stdout.read())
stdin,stdout,stderr=ssh.exec_command('ls')
print(stdout.readlines())