这个为什么报错嘞
import paramiko, getpass, sys, traceback
class sshDemo():
def __int__(self,ip, port, username, passwd):
self.ip = ip
self.port = port
self.username = username
self.passwd = passwd
self.pkey = None
def login(self, username, key_path, passwd):
try:
self.pkey = paramiko.RSAKey.from_private_key_file(key_path)
except paramiko.PasswordRequiredException:
if not passwd:
passwd = getpass.getpass('RSA key password: ')
self.pkey = paramiko.RSAKey.from_private_key_file(key_path, passwd)
def ssh(self, shell):
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
if self.pkey:
ssh.connect(self.ip, self.port, self.username, compress=True, pkey=self.pkey)
else:
if not self.passwd:
self.passwd = getpass.getpass('input password: ')
ssh.connect(self.ip, self.port, self.username, self.passwd)
stdin, stdout, stderr = ssh.exec_command(shell)
res = stdout.readlines()
ssh.close()
return res
except:
type, value, tb = sys.exc_info()
return traceback.format_exception(type, value, tb)
if __name__ == '__main__':
myssh = sshDemo("10.253.166.89", 22, "root", "123456")
# myssh.login("10.253.166.89", 22, "root", "123456")
myssh.ssh("cd /root/ && ll -a")
“class”: algorithms.Blowfish,
Traceback (most recent call last):
File “C:\Users\Administrator\Desktop\ceatest\test_lxb\ssh_shell.py”, line 62, in
myssh = sshDemo(“10.253.166.89”, 22, “root”, “123456”)
TypeError: object() takes no parameters