Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-47720

Unable to run commands on remote host with SSH Shell Script

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Unable to execute basic SSH Commands from Jenkins Freestyle Project

      SSH Command 

      ssh user@hostname -v 'cmd /c mkdir "D:\MyFolder\"' 

       
      [DemoFreestyle] $ /bin/sh -xe /apps/dftjenkins/jenkins_node/tmp/hudson3537411495764773435.sh
      + ssh dftjenkins@<IP Addess> -v 'cmd /c mkdir "D:\MyFolder\"'
      OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
      debug1: Reading configuration data /apps/dftjenkins/.ssh/config
      debug1: Reading configuration data /etc/ssh/ssh_config
      debug1: /etc/ssh/ssh_config line 56: Applying options for *
      debug1: Connecting to 10.65.136.49 [10.65.136.49] port 22.
      debug1: Connection established.
      debug1: identity file /apps/dftjenkins/.ssh/id_rsa type 1
      debug1: identity file /apps/dftjenkins/.ssh/id_rsa-cert type -1
      debug1: identity file /apps/dftjenkins/.ssh/id_dsa type -1
      debug1: identity file /apps/dftjenkins/.ssh/id_dsa-cert type -1
      debug1: identity file /apps/dftjenkins/.ssh/id_ecdsa type -1
      debug1: identity file /apps/dftjenkins/.ssh/id_ecdsa-cert type -1
      debug1: identity file /apps/dftjenkins/.ssh/id_ed25519 type -1
      debug1: identity file /apps/dftjenkins/.ssh/id_ed25519-cert type -1
      debug1: Enabling compatibility mode for protocol 2.0
      debug1: Local version string SSH-2.0-OpenSSH_6.6.1
      debug1: Remote protocol version 2.0, remote software version WeOnlyDo 2.4.3
      debug1: no match: WeOnlyDo 2.4.3
      debug1: SSH2_MSG_KEXINIT sent
      debug1: SSH2_MSG_KEXINIT received
      debug1: kex: server->client aes128-ctr hmac-md5 none
      debug1: kex: client->server aes128-ctr hmac-md5 none
      debug1: kex: ecdh-sha2-nistp256 need=16 dh_need=16
      debug1: kex: ecdh-sha2-nistp256 need=16 dh_need=16
      debug1: sending SSH2_MSG_KEX_ECDH_INIT
      debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
      debug1: Server host key: RSA 4b:0f:6b:99:06:61:9e:f0:07:77:48:01:38:35:32:03
      debug1: Host '10.65.136.49' is known and matches the RSA host key.
      debug1: Found key in /apps/dftjenkins/.ssh/known_hosts:30
      debug1: ssh_rsa_verify: signature correct
      debug1: SSH2_MSG_NEWKEYS sent
      debug1: expecting SSH2_MSG_NEWKEYS
      debug1: SSH2_MSG_NEWKEYS received
      debug1: SSH2_MSG_SERVICE_REQUEST sent
      debug1: SSH2_MSG_SERVICE_ACCEPT received
      debug1: Authentications that can continue: password,gssapi-with-mic,publickey
      debug1: Next authentication method: gssapi-with-mic
      debug1: Unspecified GSS failure. Minor code may provide more information
      No Kerberos credentials available

      debug1: Unspecified GSS failure. Minor code may provide more information
      No Kerberos credentials available

      debug1: Unspecified GSS failure. Minor code may provide more information

      debug1: Unspecified GSS failure. Minor code may provide more information
      No Kerberos credentials available

      debug1: Next authentication method: publickey
      debug1: Offering RSA public key: /apps/dftjenkins/.ssh/id_rsa
      debug1: Server accepts key: pkalg ssh-rsa blen 279
      debug1: key_parse_private2: missing begin marker
      debug1: read PEM private key done: type RSA
      debug1: Authentication succeeded (publickey).
      Authenticated to 10.65.136.49 ([10.65.136.49]:22).
      debug1: channel 0: new [client-session]
      debug1: Entering interactive session.
      debug1: Sending environment.
      debug1: Sending env LANG = en_US.UTF-8
      debug1: Sending command: cmd /c mkdir "D:
      MyFolder
      "
      debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
      debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
      channel 0: protocol error: close rcvd twice
      debug1: channel 0: free: client-session, nchannels 1
      debug1: fd 0 clearing O_NONBLOCK
      debug1: fd 1 clearing O_NONBLOCK
      Transferred: sent 3392, received 1768 bytes, in 0.8 seconds
      Bytes per second: sent 4017.4, received 2094.0
      debug1: Exit status 1
      Build step 'Execute shell' marked build as failure
      CI Activity Event Proxy 2.0 Publish Message :-
      {"status":"SUCCESS","data":{"routingKey":"cda2.ci_build_plugin.x.platform_activity.failure","message":"{\"jobName\":\"DemoFreestyle\",\"nodeName\":\"Rcdn-Node14\",\"buildTimestamp\":\"Sun Oct 29 07:08:37 PDT
       

      SSH Server Configuration

      • Windows10
      • FreeSSHd
      • Configured using Public Keys under that user

      Jenkins Configuration

      • Created Freestyle Project
      • Default Settings provided under CloudBees Enterprise

       

      Expected : 

      Folder should have got created with Jenkins

      Actual 

      No folder gets created in Remote Windows Machine 

      The Commands entered in SSH were not executed in Remote Host

       

       

       

       

        Attachments

          Activity

          Hide
          danielbeck Daniel Beck added a comment -

          As the debug log shows, the backslashes are considered escape characters in the string you pass.

          Has nothing to do with Jenkins, I'd be very surprised if this same command worked outside Jenkins.

          Show
          danielbeck Daniel Beck added a comment - As the debug log shows, the backslashes are considered escape characters in the string you pass. Has nothing to do with Jenkins, I'd be very surprised if this same command worked outside Jenkins.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            deadnight7 Chirag Pandit
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: