code: def _determine_username(self, ip):
          
          ssh = subprocess.Popen([
              "ssh",
              "-o", "UserKnownHostsFile=/dev/null",
              "-o", "StrictHostKeyChecking=no",
              "root@%s" % ip],
              stdin=subprocess.DEVNULL,
              stdout=subprocess.PIPE,
              stderr=subprocess.DEVNULL)
          first_line = ssh.stdout.readline()
          ssh.kill()
          ssh.wait()
          if first_line:
              match = re.search(
                  r"Please login as the user \"(\w+)\" rather than "
                  r"the user \"root\".", first_line.decode('utf-8'))
              if match:
                  return match.groups()[0]
          else:
              return None
docs: SSH in as root and determine the username.