连接linux
程序员文章站
2024-02-27 16:58:09
...
1.安装paramiko报错,解决方法:https://blog.csdn.net/lmj19851117/article/details/79065912
import paramiko
class paramiko_link(object):
def __init__(self,host,username,password):
self.ssh = paramiko.SSHClient()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())#自动保存主机名和**信息
self.ssh.connect(hostname=host, port=22, username=username, password=password)
def link_linux(self):
stdin,stdout,stderr = self.ssh.exec_command("ls -l")#stdin标准输入,stdout正确输出,stderr错误输出
print(stdout.read().decode())
print(stderr.read(),decode())
if __name__ == "__main__":
ssh = paramiko_link("ip","username","password")
ssh.link_linux()
上一篇: 【多项式ln+exp】付公主的背包