import paramiko
def sshExeCMD():
ssh_client=paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname="192.168.8.200",port=22,username="root",password="123")
stdin,stdout,stderr = ssh_client.exec_command("cat /etc/redhat-release;hostname;ls /")
print(str(stdout.read()))
ssh_client.close()
if __name__ == '__main__':
sshExeCMD()
实现效果:
/var/log/secure日志记录
var
密码的坑:
标签:__,python,--------------,client,ssh,var,paramiko From: https://www.cnblogs.com/cherishthepresent/p/17813817.html