Jenkins agent executes command Permission denied

The Jenkins proxy node does not have sufficient permissions to execute SCP and SSH commands. Start the agent as root user and send it; And confirm that the executing user is root. The server is ready for password free login

    stage('归档') {
        steps {
            archiveArtifacts artifacts: 'modo-cloud-access-web/target/modo-cloud-access-web-1.0.0-SNAPSHOT-assembly.tar.gz', followSymlinks: false, onlyIfSuccessful: true
        }
    }
    stage('发布') {
        steps {
            sh 'whoami'
            sh 'scp modo-cloud-access-web/target/modo-cloud-access-web-1.0.0-SNAPSHOT-assembly.tar.gz root@192.168.4.109:/web/cloud/'
            sh 'ssh 192.168.4.109 "cd /web/cloud && rm -rf modo-cloud-access-web-1.0.0-SNAPSHOT && tar -zxf modo-cloud-access-web-1.0.0-SNAPSHOT-assembly.tar.gz && dos2unix modo-cloud-access-web-1.0.0-SNAPSHOT/opbin/*"'
            sh 'ssh 192.168.4.109 "rm -rf /web/cloud/modo-cloud-access-web-1.0.0-SNAPSHOT-assembly.tar.gz"'
            sh 'ssh 192.168.4.109 "/web/cloud/modo-cloud-access-web-1.0.0-SNAPSHOT/opbin/restart.sh"'
        }
    }

Script Fragment

I doubt the job on the agent does run as root (if it does, stop doing that…).

Instead use a jenkins credential to carry the ssh key and use a sshagent step around the ssh-using part.