# Unable to execute the shell command at remote server (another server) using ansible script/shell ; even added public key of remote server to ssh

**URL:** <https://forum.ansible.com/t/unable-to-execute-the-shell-command-at-remote-server-another-server-using-ansible-script-shell-even-added-public-key-of-remote-server-to-ssh/40620>\
**Category:** Get Help\
**Tags:** rhel9\
**Created:** [February 25, 2025, 6:16pm UTC](https://forum.ansible.com/t/unable-to-execute-the-shell-command-at-remote-server-another-server-using-ansible-script-shell-even-added-public-key-of-remote-server-to-ssh/40620 "2025-02-25T18:16:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Madan\_Kumar\_Dusarlap](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/madan_kumar_dusarlap/32/7731_2.png) [@Madan\_Kumar\_Dusarlap](https://forum.ansible.com/u/Madan_Kumar_Dusarlap)\
**Post date:** [February 25, 2025, 6:16pm UTC](https://forum.ansible.com/t/unable-to-execute-the-shell-command-at-remote-server-another-server-using-ansible-script-shell-even-added-public-key-of-remote-server-to-ssh/40620/1 "2025-02-25T18:16:20Z")

</div>

- name: run emcli commands on the remote server  
hosts: dbhosts  
become: yes  
become\_user: oracle

---

<div class="post-metadata">

**Author:** ![NomakCooper](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/nomakcooper/32/7309_2.png) [@NomakCooper](https://forum.ansible.com/u/NomakCooper)\
**Post date:** [February 25, 2025, 7:37pm UTC](https://forum.ansible.com/t/unable-to-execute-the-shell-command-at-remote-server-another-server-using-ansible-script-shell-even-added-public-key-of-remote-server-to-ssh/40620/2 "2025-02-25T19:37:49Z")

</div>

Hi @Madan_Kumar_Dusarlap

I don’t think using the **`ansible.builtin.shell`** module to execute tasks on target hosts that establish SSH connections to remote servers is the right strategy.

[Ansible Connection](https://docs.ansible.com/ansible/latest/inventory_guide/connection_details.html)  
[Ansible Inventory](https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html)

Attempting an SSH connection during playbook execution could lead to issues that are external to Ansible.

I can assume that this approach stems from the fact that **`remote_server`** is not directly reachable from the control node.

Perhaps the best solution would be to configure a jump host to connect to **`remote_server`**.

Something like this :

```ini
[remote]
remote_server ansible_host=REMOTE_IP ansible_ssh_common_args='-o ProxyJump=jumphost_user@jumphost'

```
