Merge pull request #113 from XiaoliChan/ssh-fix

[ssh] fix #112
main
Alex 2023-11-10 07:26:59 -05:00 committed by GitHub
commit a440a83a2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 4 deletions

View File

@ -195,9 +195,16 @@ class ssh(connection):
with open(self.args.key_file) as f: with open(self.args.key_file) as f:
private_key = f.read() private_key = f.read()
pkey = paramiko.RSAKey.from_private_key(StringIO(private_key), password) pkey = paramiko.RSAKey.from_private_key(StringIO(private_key))
self.conn.connect(
self.conn._transport.auth_publickey(username, pkey) self.host,
port=self.port,
username=username,
passphrase=password if password != "" else None,
pkey=pkey,
look_for_keys=False,
allow_agent=False,
)
cred_id = self.db.add_credential( cred_id = self.db.add_credential(
"key", "key",
@ -208,7 +215,14 @@ class ssh(connection):
else: else:
self.logger.debug(f"Logging {self.host} with username: {self.username}, password: {self.password}") self.logger.debug(f"Logging {self.host} with username: {self.username}, password: {self.password}")
self.conn._transport.auth_password(username, password, fallback=True) self.conn.connect(
self.host,
port=self.port,
username=username,
password=password,
look_for_keys=False,
allow_agent=False,
)
cred_id = self.db.add_credential("plaintext", username, password) cred_id = self.db.add_credential("plaintext", username, password)
# Some IOT devices will not raise exception in self.conn._transport.auth_password / self.conn._transport.auth_publickey # Some IOT devices will not raise exception in self.conn._transport.auth_password / self.conn._transport.auth_publickey