Jenkins agent container

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

Hello @hedieh and welcome to this community. :wave:

You can use the SSH Agent Plugin in Jenkins to run scripts on a remote server. Here’s a basic example of how you can do this in a Jenkins pipeline:

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/"

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.