Skip to content

Commit 5a065fc

Browse files
committed
Add "none" ssh authentication method
Allow to "disable" ssh authentication if the remote server has it enabled. Fixes #2380
1 parent 27366fd commit 5a065fc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

pwnlib/tubes/ssh.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,8 @@ class ssh(Timeout, Logger):
557557

558558
def __init__(self, user=None, host=None, port=22, password=None, key=None,
559559
keyfile=None, proxy_command=None, proxy_sock=None, level=None,
560-
cache=True, ssh_agent=False, ignore_config=False, raw=False, *a, **kw):
560+
cache=True, ssh_agent=False, ignore_config=False, raw=False,
561+
auth_none=False, *a, **kw):
561562
"""Creates a new ssh connection.
562563
563564
Arguments:
@@ -571,10 +572,11 @@ def __init__(self, user=None, host=None, port=22, password=None, key=None,
571572
proxy_sock(str): Use this socket instead of connecting to the host.
572573
timeout: Timeout, in seconds
573574
level: Log level
574-
cache: Cache downloaded files (by hash/size/timestamp)
575-
ssh_agent: If :const:`True`, enable usage of keys via ssh-agent
576-
ignore_config: If :const:`True`, disable usage of ~/.ssh/config and ~/.ssh/authorized_keys
577-
raw: If :const:`True`, assume a non-standard shell and don't probe the environment
575+
cache(bool): Cache downloaded files (by hash/size/timestamp)
576+
ssh_agent(bool): If :const:`True`, enable usage of keys via ssh-agent
577+
ignore_config(bool): If :const:`True`, disable usage of ~/.ssh/config and ~/.ssh/authorized_keys
578+
raw(bool): If :const:`True`, assume a non-standard shell and don't probe the environment
579+
auth_none(bool): If :const:`True`, try to authenticate with no authentication methods
578580
579581
NOTE: The proxy_command and proxy_sock arguments is only available if a
580582
fairly new version of paramiko is used.
@@ -670,6 +672,11 @@ def __init__(self, user=None, host=None, port=22, password=None, key=None,
670672
" To remove the existing entry from your known_hosts and trust the new key, run the following commands:\n"
671673
" $ ssh-keygen -R %(host)s\n"
672674
" $ ssh-keygen -R [%(host)s]:%(port)s" % locals())
675+
except paramiko.SSHException as e:
676+
if user and auth_none and str(e) == "No authentication methods available":
677+
self.client.get_transport().auth_none(user)
678+
else:
679+
raise
673680

674681
self.transport = self.client.get_transport()
675682
self.transport.use_compression(True)

0 commit comments

Comments
 (0)