I used below command can connect the server.
ssh -i ssh-key.key rocky@123.34.43.23
but when I use ssh pipline to connect the serve,get this error:
def remoteConfig = [:]
remoteConfig.name = "my-remote-server"
remoteConfig.host = "${REMOTE_HOST}"
remoteConfig.allowAnyHosts = true
node {
withCredentials([sshUserPrivateKey(credentialsId: "${REMOTE_CRED}",keyFileVariable: 'privateKeyFilePath',passphraseVariable: '', usernameVariable: 'userName')]) {
remoteConfig.user = userName
remoteConfig.identityFile = privateKeyFilePath
stage("ssh") {
sshCommand remote: remoteConfig, command: "ls -lrt"
sshCommand remote: remoteConfig, command: "for i in {1..5}; do echo -n \"Loop \$i \"; date ; sleep 1; done"
}
}
}
Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 77c76057-e24b-499b-92bf-6b565fac42e9
com.jcraft.jsch.JSchException: Auth fail
at com.jcraft.jsch.Session.connect(Session.java:519)
at com.jcraft.jsch.Session.connect(Session.java:183)
at com.jcraft.jsch.Session$connect$1.call(Unknown Source)
at org.hidetake.groovy.ssh.connection.ConnectionManager.connectInternal(ConnectionManager.groovy:107)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:352)