Skip to content

Commit 23b4a23

Browse files
committed
Readd functionality that key files are stored to db
1 parent 7a6945a commit 23b4a23

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

nxc/protocols/ssh.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,17 @@ def plaintext_login(self, username, password, private_key=""):
9090
port=self.port,
9191
username=username,
9292
passphrase=password if password != "" else None,
93-
key_filename=private_key if private_key else self.args.key_file,
93+
pkey=private_key,
94+
key_filename=self.args.key_file,
9495
timeout=self.args.ssh_timeout,
9596
look_for_keys=False,
9697
allow_agent=False,
9798
banner_timeout=self.args.ssh_timeout,
9899
)
100+
# If we get the private key from the file, we need to load it into the database
101+
if self.args.key_file:
102+
with open(self.args.key_file) as f:
103+
private_key = f.read().rstrip("\n")
99104
cred_id = self.db.add_credential("key", username, password, key=private_key)
100105
else:
101106
self.logger.debug(f"Logging {self.host} with username: {self.username}, password: {self.password}")

0 commit comments

Comments
 (0)