Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException com.jcraft.jsch.Session cannot be cast to java.lang.String clj-ssh.ssh/session-impl #53

Open
af-fess opened this issue Jan 4, 2017 · 2 comments

Comments

@af-fess
Copy link

af-fess commented Jan 4, 2017

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
Copy link

JoePython1 commented Jan 5, 2017

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
Copy link

dpom commented Feb 28, 2021

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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants