Skip to content

Commit

Permalink
clj-commons#16 - add option to ssh-agent for :known-hosts-path
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjudd committed Oct 13, 2012
1 parent 71944f1 commit 45d6f12
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/clj_ssh/ssh.clj
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@
;;; Agent
(defn ssh-agent
"Create a ssh-agent. By default a system ssh-agent is preferred."
[{:keys [use-system-ssh-agent] :or {use-system-ssh-agent true}}]
(if use-system-ssh-agent
(doto (JSch.) (agent/connect))
(JSch.)))

[{: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
(.setKnownHosts agent known-hosts-path))
agent))

;;; Identities
(defn has-identity?
Expand Down

0 comments on commit 45d6f12

Please sign in to comment.