我正在尝试通过ssh连接到远程计算机,并尝试在该计算机上执行一些脚本。下面是我的代码。
def remote = [:]
remote.name = "ssh server"
remote.host = "****"
remote.allowAnyHosts = true
node {
withCredentials([sshUserPrivateKey(credentialsId: 'server-user', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'userName')]) {
remote.user = userName
remote.identityFile = identity
stage("SSH Steps Rocks!") {
sshCommand remote: remote, command: 'hostname'
}
}
}
当尝试执行此代码时,我收到JNLP4-connect错误。我在詹金斯全局凭证中添加了私钥。我在这里做错了什么?请帮忙。预先感谢。
下面是几行日志。
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1743)
at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
at hudson.remoting.Channel.call(Channel.java:957)
at org.jenkinsci.plugins.sshsteps.steps.CommandStep$Execution.run(CommandStep.java:72)
at org.jenkinsci.plugins.sshsteps.util.SSHStepExecution.lambda$start$0(SSHStepExecution.java:84)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
com.jcraft.jsch.JSchException: Auth cancel
at com.jcraft.jsch.Session.connect(Session.java:518)
at com.jcraft.jsch.Session.connect(Session.java:183)