# SSH in shell command

**URL:** <https://forum.ansible.com/t/ssh-in-shell-command/33040>\
**Category:** Ansible Project\
**Created:** [May 28, 2020, 3:53pm UTC](https://forum.ansible.com/t/ssh-in-shell-command/33040 "2020-05-28T15:53:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sivaraman\_P](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sivaraman\_P](https://forum.ansible.com/u/Sivaraman_P)\
**Post date:** [May 28, 2020, 3:53pm UTC](https://forum.ansible.com/t/ssh-in-shell-command/33040/1 "2020-05-28T15:53:44Z")

</div>

I am new to ansible, i have the script in the remote machine and the script name is ssh.sh which contains below lines to ssh into some another server and run the script,

ssh @${server} "sh /tmp/script.sh"

the question is if i use shell module to call to the script ssh.sh in the playbook as below, will the ssh command with the above line will work or not???

- hosts: all  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- name: invoke the script  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shell: sh ssh.sh  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: result

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [May 28, 2020, 5:44pm UTC](https://forum.ansible.com/t/ssh-in-shell-command/33040/2 "2020-05-28T17:44:48Z")

</div>

So what's the purpose of this task and why do you need Ansible for it?

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke
