# Jenkins agent container

**URL:** <https://community.jenkins.io/t/jenkins-agent-container/11627>\
**Category:** Using Jenkins\
**Tags:** question, docker\
**Created:** [January 7, 2024, 7:37am UTC](https://community.jenkins.io/t/jenkins-agent-container/11627 "2024-01-07T07:37:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hedieh](https://avatars.discourse-cdn.com/v4/letter/h/53a042/32.png) [@hedieh](https://community.jenkins.io/u/hedieh)\
**Post date:** [January 7, 2024, 7:37am UTC](https://community.jenkins.io/t/jenkins-agent-container/11627/1 "2024-01-07T07:37:58Z")

</div>

I have a problem with Jenkins agent, I need agent to run a bashscript in other server what save in the host, I did it in Jenkins controller just by mounting hosted to the controller container.  
That is awful agent cant access to any part of controller, and I need to run this bashscript in SSH.  
thank you for helping

---

<div class="post-metadata">

**Author:** ![poddingue](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/poddingue/32/985_2.png) [@poddingue](https://community.jenkins.io/u/poddingue)\
**Post date:** [January 11, 2024, 10:18am UTC](https://community.jenkins.io/t/jenkins-agent-container/11627/2 "2024-01-11T10:18:46Z")

</div>

Hello @hedieh and welcome to this community. 👋

You can use the [SSH Agent Plugin](https://plugins.jenkins.io/ssh-agent/) in Jenkins to run scripts on a remote server. Here’s a basic example of how you can do this in a Jenkins pipeline:

```auto
pipeline {
    agent any
    stages {
        stage('Run script on remote server') {
            steps {
                // Use the sshagent step provided by the SSH Agent Plugin
                sshagent(['my-ssh-credentials-id']) {
                    // Use the sh step to run your script
                    sh '''
                        ssh user@remote-server "bash /path/to/your/script.sh"
                    '''
                }
            }
        }
    }
}

```

The `sshagent` step provided by the SSH Agent Plugin allows Jenkins to use your SSH credentials for the commands inside the step.  
The `sh` step is used to run the SSH command that executes your script on the remote server.

Replace `my-ssh-credentials-id` with the ID of your SSH credentials in Jenkins.
