Search code examples
javasshclojurejnajsch

clj-ssh / JSch unable to load library 'c' on Windows


I've added clj-ssh as a dependency to a Leiningen project, and I can (use 'clj-ssh.ssh) but calling (ssh-agent {}) gives the error

UnsatisfiedLinkError Unable to load library 'c': The specified module cannot be found.
at com.sun.jna.NativeLibrary.loadNativeLibrary
...
at org.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory$CLibrary.(clinit)
...

Anyone know why this is? I'm thinking it could be to do with Windows not coming with a C standard library, in which case could installing e.g. cygwin help?


Solution

  • Ok, after some digging in the source it seems that clj-ssh attempts to use the system ssh-agent by default (which seems like strange behaviour if it isn't windows compatible). This makes clj-ssh.cli unusable but clj-ssh.ssh is fine with the fix

    (ssh-agent {:use-system-ssh-agent false})
    

    If you do want to use a system ssh-agent, the readme for clj-ssh and ymnk below mention PuTTY's pageant, I couldn't find any info on setting this up but it should be doable with cygwin.