int128 / groovy-ssh

SSH automation tool based on Groovy DSL
https://gradle-ssh-plugin.github.io
Apache License 2.0
115 stars 25 forks source link

Windows user : com.jcraft.jsch.AgentProxyException: SSH_AUTH_SOCK is not defined. #329

Open deguich opened 1 year ago

deguich commented 1 year ago

Environment info

On windows 11

Steps to reproduce

Working gradle plugin version :

plugins {
    ...
    id "org.hidetake.ssh" version "2.10.1"
}

Broken version :

plugins {
    ...
    id "org.hidetake.ssh" version "2.11.2"
}

Error :

* What went wrong:
Execution failed for task ':deployApp'.
> com.jcraft.jsch.AgentProxyException: SSH_AUTH_SOCK is not defined.

This is the same task code used for twice version :

remotes {
  deployServer {
    host = deployServerHost
    knownHosts = allowAnyHosts
    user = deployServerUser
    agent = true
    identity = file(deployServerOpenSSHKey)
  }
}

task deployApp {
  group 'deploy'
  description 'Copy to server.'
  dependsOn copyAllDependencies
  doLast {
    ssh.run {
      session(remotes.deployServer) {
        put from: fileTree(dir: 'allLibs', include: ['*.jar']), into: '/tmp/test'
      }
    }
  }
}

Is there a solution to force using PageantConnector ? https://github.com/mwiede/jsch/issues/65#issuecomment-913051572

deguich commented 1 year ago

Hi

If I well understand this comment https://github.com/mwiede/jsch/issues/65#issuecomment-913051572 They said PageantConnector class have not been tested but this class is always needed to make a pagent connection.

They also spoke about jsch-agent-proxy having a solution to optimize SSHAgentConnector. It fallback ssh-agent support to junix socket or usocket ... but it never return a PagentConnector.

They also mentioned that jsch-agent-proxy offers a solution to optimize SSHAgentConnector. It use junix socket and can fall back to usocket, but it does not fall back to PagentConnector.

jsch-agent-proxy lib used a com.jcraft.jsch.agentproxy.ConnectorFactory to retrieve automatically ssh-agent or pagent connector.

I think it is not the case for org.hidetake.groovy.ssh.connection.UserAuthentication, it use only SSHAgentConnector :

if (settings.agent) {
    // Use agent authentication using https://github.com/mwiede/jsch/issues/65#issuecomment-913051572
    IdentityRepository irepo = new AgentIdentityRepository(new SSHAgentConnector())
        jsch.identityRepository = irepo
        log.debug("Using SSH agent authentication for $remote")
}

Do you think it could be the cause of my issue ? Thx