Using Python Exscript to connect to an AIX box
Question: Here is the code that I am using. For some reasons it is not working, what am
I missing? Not sure what else I can add to my post but the site is asking me
to add more details

    
    
    account = Account(name= 'MiniMe', password = 'password')
    conn = SSH2()
    conn.debug=5
    
    try:
        print "Attempting a connection to 1.1.1.1"
        conn.connect('1.1.1.1')
        print (conn.response)
    except:
        e = sys.exc_info()[0]
        print "Error connecting to host:", e
        conn="N/A"
    
    
    try:
        print "Authenticating to 1.1.1.1"
        conn.login(account)
        print (conn.response)
    except:
        e = sys.exc_info()[0]
        print e
    
    conn.execute('ls -la')
    print (conn.response)
    

The output looks like this

    
    
    Attempting a connection to  1.1.1.1.
    generic: Rejecting ssh-rsa host key for 1.1.1.1: 3432432j4k32j4k32j42j34kj432
    generic: Attempting to authenticate MiniMe
    generic: Authenticating with _paramiko_auth_password
    None
    Authenticating to  1.1.1.1
    generic: Attempting to app-authenticate MiniMe.
    generic: waiting for: ['[\\r\\n][^\\r\\n]*(?:bad secrets|denied|invalid|too short|incorrect|connection timed out|failed|failure)', 'login as:', '(?:s\\/key|otp-md4) (\\d+) (\\S+)', 'password:? *$', '[\\r\\n](?:[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\\!\\"\\#\\$\\%\\&\\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~\\ \\\t\\\n\\\r\\\x0b\\\x0c]*|[\\x1b\\x07\\x00]*)[\\[\\<]?\\w+(?:(?:(?:[\\w+\\-]+)\\@)?(?:[\\w+\\-\\.]+))?:?(?:(?:(?:(?:[\\w\\+\\-\\._]+))?(?:/(?:[\\w\\+\\-\\._]+))*/?)|~(?:(?:(?:[\\w\\+\\-\\._]+))?(?:/(?:[\\w\\+\\-\\._]+))*/?)?)?[: ]?(?:(?:(?:(?:[\\w\\+\\-\\._]+))?(?:/(?:[\\w\\+\\-\\._]+))*/?)|~(?:(?:(?:[\\w\\+\\-\\._]+))?(?:/(?:[\\w\\+\\-\\._]+))*/?)?)?(?:\\((?:[\\w\\+\\-\\._]+)\\))?[\\]\\-]?[#>%\\$\\]] ?[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\\!\\"\\#\\$\\%\\&\\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~\\ \\\t\\\n\\\r\\\x0b\\\x0c]*\\Z']
    generic: Expecting a prompt
    generic: Expected pattern: <generator object <genexpr> at 0x000000000349C990>
    aix: Protocol: driver replaced: generic -> aix
    aix: Protocol.app_authenticate(): driver replaced
    aix: waiting for: ['[\\r\\n][^\\r\\n]*(?:bad secrets|denied|invalid|too short|incorrect|connection timed out|failed|failure)', 'login as:', '(?:s\\/key|otp-md4) (\\d+) (\\S+)', "[\\r\\n]\\w+\\'s Password: $", '[\\r\\n](?:[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\\!\\"\\#\\$\\%\\&\\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~\\ \\\t\\\n\\\r\\\x0b\\\x0c]*|[\\x1b\\x07\\x00]*)[\\[\\<]?\\w+(?:(?:(?:[\\w+\\-]+)\\@)?(?:[\\w+\\-\\.]+))?:?(?:(?:(?:(?:[\\w\\+\\-\\._]+))?(?:/(?:[\\w\\+\\-\\._]+))*/?)|~(?:(?:(?:[\\w\\+\\-\\._]+))?(?:/(?:[\\w\\+\\-\\._]+))*/?)?)?[: ]?(?:(?:(?:(?:[\\w\\+\\-\\._]+))?(?:/(?:[\\w\\+\\-\\._]+))*/?)|~(?:(?:(?:[\\w\\+\\-\\._]+))?(?:/(?:[\\w\\+\\-\\._]+))*/?)?)?(?:\\((?:[\\w\\+\\-\\._]+)\\))?[\\]\\-]?[#>%\\$\\]] ?[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\\!\\"\\#\\$\\%\\&\\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~\\ \\\t\\\n\\\r\\\x0b\\\x0c]*\\Z']
    aix: Expecting a prompt
    aix: Expected pattern: <generator object <genexpr> at 0x000000000349C9D8>
    aix: Sending 'ls -la\r'
    <class 'Exscript.protocols.Exception.TimeoutException'>
    aix: Expecting a prompt
    aix: Expected pattern: <generator object <genexpr> at 0x000000000349CAB0>
    


Answer: Here are the key lines from the output:

    
    
    Attempting a connection to  1.1.1.1.
    # ... (messages from AIX)
    None
    # ... (messages from AIX)
    Authenticating to  1.1.1.1
    # ... (messages from AIX)
    <class 'Exscript.protocols.Exception.TimeoutException'>
    # ... (messages from AIX)
    

These are the printed messages from the two try/except statements. Here's the
**most important line:**

    
    
    print (conn.response)
    #=> None
    

... happens after an attempted connection.

The connection isn't working. The connection receives a blank response, i.e.
`None`, and then it prints it out. That also explains the `TimeoutException`
lower down. `Timeout` essentially means "I asked for Internet, and received
silence." (The way this program is written, it will attempt to authenticate
even when the initial connection fails. Don't worry, it's easily fixed.)

Maybe the IP address is mistyped? Alternatively, try adding `http://` in front
of the URL.

