How to use ansible to proxy commands through a remote server to the target remote server

In our work setup , there is a remote server B which is accessible only via a remote server A .

  • How can i run ansible commands/playbooks on remote server B through remote server A from my local system where ansible runs ,ie, local system --> remote server A --> remote server B
  • The remote server B is accessible via remote server A through ssh . But i do not have access to the ssh keys to remote server B

this is what i tried to do in my inventory.yaml file based on the answer below

    ansible_connection: "ssh"
    ansible_user: "userB"
    ansible_ssh_common_args: '-o ProxyCommand="sshpass -p <password> ssh -W %h:%p -q [email protected]erA"' 

but i get the following error from ansible

UNREACHABLE  {"changed": false, "msg": "EOF on stream; last 100 lines received:\nssh_exchange_identification: Connection closed by remote host\r", "unreachable": true}