'Log into ssh server, check banner, then exit'

def connected(self, ip):

    p = pexpect.spawn(('ssh    -i    /tmp/ssh/test_rsa    %s' % ip), timeout=10)
    while True:
        index = p.expect(self.opts)
        if (index == 0):
            print p.match.group(0)
            p.sendline('yes')
        elif (index == 1):
            return False
        elif (index == 2):
            p.sendline('exit')
            p.wait()
            return True
        else:
            return False
