A brief demonstration of how to run Clojure programs like scripts with leiningen.

#!/home/callen/bin/lein exec
(use '[leiningen.exec :only (deps)])
(deps '[[clj-ssh "0.5.5"]])
(use 'clj-ssh.ssh)

(println "Hello!")

(let [agent (ssh-agent {})]
  (add-identity agent {:private-key-path "/user/.ssh/id_rsa"})
  (let [session (session agent "localhost" {:strict-host-key-checking :no})]
    (with-connection session
      (let [result (ssh session {:in "ssh [email protected] ls" :agent-forwarding true})]
        (println (result :out))))))
lein exec my-script.clj