# Execute shell script on remote machine using ssh once the build is manually aborted in jenkins

**URL:** <https://community.jenkins.io/t/execute-shell-script-on-remote-machine-using-ssh-once-the-build-is-manually-aborted-in-jenkins/13137>\
**Category:** Ask a question\
**Tags:** question\
**Created:** [March 8, 2024, 2:30am UTC](https://community.jenkins.io/t/execute-shell-script-on-remote-machine-using-ssh-once-the-build-is-manually-aborted-in-jenkins/13137 "2024-03-08T02:30:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashish\_k](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/ashish_k/32/7334_2.png) [@ashish\_k](https://community.jenkins.io/u/ashish_k)\
**Post date:** [March 8, 2024, 2:30am UTC](https://community.jenkins.io/t/execute-shell-script-on-remote-machine-using-ssh-once-the-build-is-manually-aborted-in-jenkins/13137/1 "2024-03-08T02:30:59Z")

</div>

Hi all,

I’m using a freestyle jenkins project and wanted to execute a shell script on a remote host only when the build is manually aborted. Is there any feature/plugins to support this requirement ?

I’ve used : ssh, ssh-agent and publish-over-ssh plugins , but can’t see the option to ‘execute the ssh commands to remote server’ in ‘Add post-build action’ tab .  
There’s ‘Post Build Task’ plugin as well, but I believe there’s no option to execute scripts over remote machine ??

Also, I’m not sure how can I add execute the script only when the build is aborted .

Any help is most welcome!

---

<div class="post-metadata">

**Author:** ![ashish\_k](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/ashish_k/32/7334_2.png) [@ashish\_k](https://community.jenkins.io/u/ashish_k)\
**Post date:** [March 8, 2024, 3:07pm UTC](https://community.jenkins.io/t/execute-shell-script-on-remote-machine-using-ssh-once-the-build-is-manually-aborted-in-jenkins/13137/2 "2024-03-08T15:07:53Z")

</div>

Hello ,  
any expert’s comments on this please ?  
thanks

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [March 8, 2024, 7:00pm UTC](https://community.jenkins.io/t/execute-shell-script-on-remote-machine-using-ssh-once-the-build-is-manually-aborted-in-jenkins/13137/3 "2024-03-08T19:00:41Z")

</div>

with [PostBuildScript](https://plugins.jenkins.io/postbuildscript/) plugin you can run a shell step when the build is aborted.
