Skip to content

Commit d8161b1

Browse files
ninjuddhugoduncan
authored andcommitted
#16 - add option to ssh-agent for :known-hosts-path
1 parent fefc7aa commit d8161b1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/clj_ssh/ssh.clj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,15 @@
9393
;;; Agent
9494
(defn ssh-agent
9595
"Create a ssh-agent. By default a system ssh-agent is preferred."
96-
[{:keys [use-system-ssh-agent] :or {use-system-ssh-agent true}}]
97-
(if use-system-ssh-agent
98-
(doto (JSch.) (agent/connect))
99-
(JSch.)))
100-
96+
[{:keys [use-system-ssh-agent known-hosts-path]
97+
:or {use-system-ssh-agent true
98+
known-hosts-path (str (. System getProperty "user.home") "/.ssh/known_hosts")}}]
99+
(let [agent (JSch.)]
100+
(when use-system-ssh-agent
101+
(agent/connect agent))
102+
(when known-hosts-path
103+
(.setKnownHosts agent known-hosts-path))
104+
agent))
101105

102106
;;; Identities
103107
(defn has-identity?

0 commit comments

Comments
 (0)