Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSHException("No authentication methods available") #2380

Open
George-TL opened this issue Apr 1, 2024 · 3 comments · May be fixed by #2405
Open

SSHException("No authentication methods available") #2380

George-TL opened this issue Apr 1, 2024 · 3 comments · May be fixed by #2405

Comments

@George-TL
Copy link

I'm trying to use pwn in the following CTF:
ssh -v [email protected]

From ssh@bash I can connect without any issues.
Server do not asks for any password and runs challange straight away.

This line is interesting
Authenticated to misc.challenges.qctf.ca ([45.63.2.192]:22) using "none".

But in python:
ssh_conn = pwn.tubes.ssh.ssh(user = 'lucky', host = 'misc.challenges.qctf.ca')

I'm getting following error message:
raise SSHException("No authentication methods available")
paramiko.ssh_exception.SSHException: No authentication methods available

Additional read:
https://stackoverflow.com/a/71750537

I've dig through pwnlib documentation and didn't find any solution.
If there is a way to interact with such service then please point me to the right direction.

@Arusekk
Copy link
Member

Arusekk commented Apr 2, 2024

This is most likely a bug in paramiko, not pwntools. Please see if updating paramiko helps, if not, please file your report there.

@peace-maker
Copy link
Member

This seems to work

diff --git a/pwnlib/tubes/ssh.py b/pwnlib/tubes/ssh.py
index 53b8be0d..ab481650 100644
--- a/pwnlib/tubes/ssh.py
+++ b/pwnlib/tubes/ssh.py
@@ -674,6 +674,11 @@ class ssh(Timeout, Logger):
                            "    To remove the existing entry from your known_hosts and trust the new key, run the following co>
                            "        $ ssh-keygen -R %(host)s\n"
                            "        $ ssh-keygen -R [%(host)s]:%(port)s" % locals())
+            except paramiko.SSHException as e:
+                if str(e) == "No authentication methods available":
+                    self.client.get_transport().auth_none(user)
+                else:
+                    raise

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

with

from pwn import *
io = ssh('lucky', 'misc.challenges.qctf.ca', raw=True)
io.interactive()

I don't think this is a commonly used "authentication" service which gets added to paramiko's SSHClient, so I'd be fine with adding this along with a new parameter like auth_none=False to tubes.ssh?

@George-TL
Copy link
Author

I can confirm that above patch works fine under Python/3.11.8 and pwntools/4.12.0.
Thank you!

peace-maker added a commit to peace-maker/pwntools that referenced this issue Apr 22, 2024
Allow to "disable" ssh authentication if the remote server has it enabled.

Fixes Gallopsled#2380
@peace-maker peace-maker linked a pull request May 12, 2024 that will close this issue
peace-maker added a commit to peace-maker/pwntools that referenced this issue May 12, 2024
Allow to "disable" ssh authentication if the remote server has it enabled.

Fixes Gallopsled#2380
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants