views:

96

answers:

1

Hi all,

I am trying to get supported auth methods from a running SSH server in Python. I found this method in the ServerInterface class in Paramiko but I can't understand if it is usable in a simple client-like snippet of code (I am writing something that accomplish in ONLY this task).

Anyone can suggest me some links with examples, other the distribution documentation? Maybe any other ideas to do this?

Thanks.

A: 

You can try to authenticate using no authentication, which should always fail, but the server will then send back the auth types that can continue. There is an auth_none() method provided by paramiko.Transport to do this.

import paramiko
import socket

s = socket.socket()
s.connect(('localhost', 22))
t = paramiko.Transport(s)
t.connect()

try:
    t.auth_none('')
except paramiko.BadAuthenticationType, err:
    print err.allowed_types
JimB