Maybe ```remote.handle_prompts(session, None, None, r"[\#\$]\s*$")``` here can solve the problem.