get_allowed_auths() in paramiko for authentication types
Question: I am trying to get supported authentication types/methods from a running SSH
server in Python.

I found this method get_allowed_auths() 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.


Answer: 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
    

