ClassCastException com.jcraft.jsch.Session cannot be cast to java.lang.String clj-ssh.ssh/session-impl
af-fess opened this issue · 2 comments
af-fess commented
I try to run command on remote machine, I success to connect through my MAC over ssh without password (use known_host
)
so I run through REPL
:
(let [agent (clj-ssh.ssh/ssh-agent {})]
(clj-ssh.ssh/add-identity agent {
:known-hosts-path "/Users/maxim/.ssh/known_hosts"
:private-key-path "/Users/maxim/.ssh/id_rsa"
:public-key-path "/Users/maxim/.ssh/id_rsa.pub"
})
(let [session (clj-ssh.ssh/session agent "ops-ev19.comp.com" {:username "maxim" :strict-host-key-checking :no})]
(clj-ssh.ssh/with-connection session
(let [result (ssh session {:cmd "ls"})]
(println (:out result))))))
and get error:
ClassCastException com.jcraft.jsch.Session cannot be cast to java.lang.String clj-ssh.ssh/session-impl (ssh.clj:318)
I use [clj-ssh "0.5.14"]
Any ideas?
JoePython1 commented
What happens if you try this:
(let [agent (ssh-agent {:use-system-ssh-agent false})]
(add-identity agent {:private-key-path "/Users/maxim/.ssh/id_rsa"})
(let [session (session agent "ops-ev19.comp.com" {:username "maxim" :strict-host-key-checking :no})]
(with-connection session
(let [result (ssh session {:cmd "ls"})]
(println (result :out))))))```
dpom commented
I have the same error with the above code:
Execution error (ClassCastException) at clj-ssh.ssh/session-impl (ssh.clj:318).
class com.jcraft.jsch.Session cannot be cast to class java.lang.String (com.jcraft.jsch.Session is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')