diff --git a/.travis.yml b/.travis.yml index 58f734a..9d4a201 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: clojure -lein: lein2 +lein: lein before_script: - ssh-keygen -N "" -f ~/.ssh/id_rsa - cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys @@ -11,9 +11,9 @@ before_script: - echo "clj-ssh" > pp - chmod +x pp - setsid ssh-add ~/.ssh/clj_ssh_pp < pp -script: lein2 test +script: lein test after_success: -- lein2 pallet-release push +- lein pallet-release push env: global: secure: eOBqYhJhOJMtRiMKs9ZgG4pEHFy7YqiBZ5NUEWUYD6qav6sMRHqqR5F04NRI37SmnIupzeTChqfRgX0DOwHeTl4u+QJnwRDH2z3avu75FbtZWgiGrxzE39SESpVj/zsyDrEUzT7ZiMayXKyNa3ObiJ8vBUFT7x/OZyRp/1rJxHU= diff --git a/README.md b/README.md index c950da8..1c58113 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,20 @@ system, then a local, isolated ssh-agent can be used. (let [result (ssh session {:in "echo hello"})] (println (result :out))))) ``` +If the known_hosts file is not in the default location, and you don't need to read it anyways, +because you turned off strict-host-key-checking, you can advise ssh-agent to not attempt to +read the known_hosts file + +```clj +(let [agent (ssh-agent {:use-system-ssh-agent false + :known-hosts-path :no-default-path})] + (add-identity agent {:private-key-path "/user/name/.ssh/id_rsa"}) + (let [session (session agent "host-ip" {:strict-host-key-checking :no})] + (with-connection session + (let [result (ssh session {:in "echo hello"})] + (println (result :out))))) +``` + SFTP is supported: diff --git a/src/clj_ssh/ssh.clj b/src/clj_ssh/ssh.clj index d0ec38b..983c04d 100644 --- a/src/clj_ssh/ssh.clj +++ b/src/clj_ssh/ssh.clj @@ -139,14 +139,14 @@ (defn ssh-agent "Create a ssh-agent. By default a system ssh-agent is preferred." - [{:keys [use-system-ssh-agent ^String known-hosts-path] + [{:keys [use-system-ssh-agent known-hosts-path] :or {use-system-ssh-agent true known-hosts-path (str (. System getProperty "user.home") "/.ssh/known_hosts")}}] (let [agent (JSch.)] (when use-system-ssh-agent (agent/connect agent)) - (when known-hosts-path + (when-not (= :no-default-path known-hosts-path) (locking hosts-file (.setKnownHosts agent known-hosts-path))) agent))