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

Auth fail on provisioned agent

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Duplicate
    • Icon: Critical Critical
    • _unsorted
    • None

      I created a new managed disk azure image with sshd_config as follows:

      ```

      PermitRootLogin without-password

      AuthorizedKeysCommand /usr/local/bin/userkeys.sh

      AuthorizedKeysCommandUser nobody

      AuthorizedKeysFile .ssh/authorized_keys

      ChallengeResponseAuthentication no

      UsePAM yes

      X11Forwarding yes

      PrintMotd no

      AcceptEnv LANG LC_*

      Subsystem sftp /usr/lib/openssh/sftp-server

      ```

      VM has user names `jenkins` with ssh keys to allow ssh key auth from Jenkins. Tested and working. 

       

      When a template uses this image the VM is created and Auth fails

      ```

       

      {{2021-02-24 16:52:34.877+0000 [id=464371] SEVERE c.m.a.v.r.AzureVMAgentSSHLauncher#getRemoteSession: AzureVMAgentSSHLauncher: getRemoteSession: Got exception while connecting to remote host linux-image-test369e60.westeurope.cloudapp.azure.com:22
      com.jcraft.jsch.JSchException: Auth fail
      at com.jcraft.jsch.Session.connect(Session.java:512)
      at com.jcraft.jsch.Session.connect(Session.java:183)
      at com.microsoft.azure.vmagent.remote.AzureVMAgentSSHLauncher.getRemoteSession(AzureVMAgentSSHLauncher.java:307)
      at com.microsoft.azure.vmagent.remote.AzureVMAgentSSHLauncher.connectToSsh(AzureVMAgentSSHLauncher.java:465)
      at com.microsoft.azure.vmagent.remote.AzureVMAgentSSHLauncher.launch(AzureVMAgentSSHLauncher.java:115)
      at hudson.slaves.SlaveComputer.lambda$_connect$0(SlaveComputer.java:294)
      at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
      at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
      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)
      at java.lang.Thread.run(Thread.java:748)}}

      ```

       

      Other images created in the same manner works as expected. 

       

      Debug of SSHD on VM which fails 

      ```

      Feb 25 13:30:34 linux-image-test907690 sshd[2348]: debug1: Forked child 2399.
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: Set /proc/self/oom_score_adj to 0
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: inetd sockets after dupping: 3, 3
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: Connection from 10.0.0.100 port 40088 on 10.43.240.4 port 22
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: Client protocol version 2.0; client software version JSCH-0.1.53
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: no match: JSCH-0.1.53
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u2
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: permanently_set_uid: 107/65534 [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: SSH2_MSG_KEXINIT sent [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: SSH2_MSG_KEXINIT received [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: kex: algorithm: ecdh-sha2-nistp256 [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: kex: host key algorithm: ssh-rsa [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha1 compression: none [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha1 compression: none [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: rekey after 4294967296 blocks [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: SSH2_MSG_NEWKEYS sent [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: expecting SSH2_MSG_NEWKEYS [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: SSH2_MSG_NEWKEYS received [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: rekey after 4294967296 blocks [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: KEX done [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: userauth-request for user jenkins service ssh-connection method none [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: attempt 0 failures 0 [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: PAM: initializing for "jenkins"
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: PAM: setting PAM_RHOST to "10.0.0.100"
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: PAM: setting PAM_TTY to "ssh"
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: userauth-request for user jenkins service ssh-connection method password [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: debug1: attempt 1 failures 0 [preauth]
      Feb 25 13:30:34 linux-image-test907690 sshd[2399]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=10.0.0.100 user=jenkins
      Feb 25 13:30:36 linux-image-test907690 sshd[2399]: debug1: PAM: password authentication failed for jenkins: Authentication failure
      Feb 25 13:30:36 linux-image-test907690 sshd[2399]: Failed password for jenkins from 10.0.0.100 port 40088 ssh2
      Feb 25 13:30:37 linux-image-test907690 sshd[2399]: error: Received disconnect from 10.0.0.100 port 40088:3: com.jcraft.jsch.JSchException: Auth fail [preauth]
      Feb 25 13:30:37 linux-image-test907690 sshd[2399]: Disconnected from authenticating user jenkins 10.0.0.100 port 40088 [preauth]
      Feb 25 13:30:37 linux-image-test907690 sshd[2399]: debug1: do_cleanup [preauth]
      Feb 25 13:30:37 linux-image-test907690 sshd[2399]: debug1: monitor_read_log: child log fd closed
      Feb 25 13:30:37 linux-image-test907690 sshd[2399]: debug1: do_cleanup
      Feb 25 13:30:37 linux-image-test907690 sshd[2399]: debug1: PAM: cleanup
      Feb 25 13:30:37 linux-image-test907690 sshd[2399]: debug1: Killing privsep child 2400
      Feb 25 13:30:37 linux-image-test907690 sshd[2399]: debug1: audit_event: unhandled event 12

      ```

       

       

            azure_devops Azure DevOps
            hentis Henti Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: