Skip to content

Commit b0ccbe2

Browse files
committed
Fix ssh authentication with encrypted ssh file
1 parent af9656e commit b0ccbe2

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

nxc/protocols/ssh.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,9 @@ def check_if_admin_sudo(self):
182182
self.logger.error("Command: 'mkfifo' unavailable, running command with 'sudo' failed")
183183
return
184184

185-
def plaintext_login(self, username, password, private_key=None):
185+
def plaintext_login(self, username, password, private_key=""):
186186
self.username = username
187187
self.password = password
188-
private_key = ""
189188
stdout = None
190189
try:
191190
if self.args.key_file or private_key:
@@ -195,7 +194,7 @@ def plaintext_login(self, username, password, private_key=None):
195194
with open(self.args.key_file) as f:
196195
private_key = f.read()
197196

198-
pkey = paramiko.RSAKey.from_private_key(StringIO(private_key))
197+
pkey = paramiko.RSAKey.from_private_key(StringIO(private_key), password)
199198
self.conn.connect(
200199
self.host,
201200
port=self.port,
@@ -231,7 +230,7 @@ def plaintext_login(self, username, password, private_key=None):
231230
except Exception as e:
232231
if self.args.key_file:
233232
password = f"{process_secret(password)} (keyfile: {self.args.key_file})"
234-
if "OpenSSH private key file checkints do not match" in str(e):
233+
if "OpenSSH private key file checkints do not match" in str(e) or "password and salt must not be empty" in str(e):
235234
self.logger.fail(f"{username}:{password} - Could not decrypt key file, wrong password")
236235
else:
237236
self.logger.fail(f"{username}:{password} {e}")

0 commit comments

Comments
 (0)