code: def _init_ubuntu_user(self):
          
  
          # TODO: Test this on an image without the ubuntu user setup.
  
          auth_user = self.user
          ssh = None
          try:
              # Run w/o allocating a pty, so we fail if sudo prompts for a passwd
              ssh = self._get_ssh_client(
                  self.host,
                  "ubuntu",
                  self.private_key_path,
              )
  
              stdout, stderr = self._run_command(ssh, "sudo -n true", pty=False)
          except paramiko.ssh_exception.AuthenticationException as e:
              raise e
          else:
              auth_user = "ubuntu"
          finally:
              if ssh:
                  ssh.close()
  
          # if the above fails, run the init script as the authenticated user
  
          # Infer the public key
          public_key = None
          public_key_path = "{}.pub".format(self.private_key_path)
  
          if not os.path.exists(public_key_path):
              raise FileNotFoundError(
                  "Public key '{}' doesn't exist.".format(public_key_path)
              )
  
          with open(public_key_path, "r") as f:
              public_key = f.readline()
  
          script = INITIALIZE_UBUNTU_SCRIPT.format(public_key)
  
          try:
              ssh = self._get_ssh_client(
                  self.host,
                  auth_user,
                  self.private_key_path,
              )
  
              self._run_command(
                  ssh,
                  ["sudo", "/bin/bash -c " + shlex.quote(script)],
                  pty=True
              )
          except paramiko.ssh_exception.AuthenticationException as e:
              raise e
          finally:
              ssh.close()
  
          return True
docs: Initialize the ubuntu user.
  
          :return: bool: If the initialization was successful
          :raises: :class:`paramiko.ssh_exception.AuthenticationException`
              if the authentication fails