|
93 | 93 | ;;; Agent
|
94 | 94 | (defn ssh-agent
|
95 | 95 | "Create a ssh-agent. By default a system ssh-agent is preferred."
|
96 |
| - [{:keys [use-system-ssh-agent known-hosts-path] |
| 96 | + [{:keys [use-system-ssh-agent ^String known-hosts-path] |
97 | 97 | :or {use-system-ssh-agent true
|
98 |
| - known-hosts-path (str (. System getProperty "user.home") "/.ssh/known_hosts")}}] |
| 98 | + known-hosts-path (str (. System getProperty "user.home") |
| 99 | + "/.ssh/known_hosts")}}] |
99 | 100 | (let [agent (JSch.)]
|
100 | 101 | (when use-system-ssh-agent
|
101 | 102 | (agent/connect agent))
|
|
145 | 146 | ;; LocalIdentityRepository is not public, so we can't use
|
146 | 147 | ;; instance?
|
147 | 148 | (= "com.jcraft.jsch.LocalIdentityRepository"
|
148 |
| - (.getName (type id-repo))))] |
| 149 | + (.getName ^Class (type id-repo))))] |
149 | 150 | (cond
|
150 | 151 | identity
|
151 | 152 | (.addIdentity agent identity passphrase)
|
152 | 153 |
|
153 | 154 | (and public-key private-key)
|
154 |
| - (let [id-repo (id-repository)] |
| 155 | + (let [^com.jcraft.jsch.IdentityRepository id-repo (id-repository)] |
155 | 156 | (if (local-repo? id-repo)
|
156 | 157 | (.addIdentity agent name private-key public-key passphrase)
|
157 | 158 | (let [keypair (KeyPair/load agent private-key-path public-key-path)]
|
|
160 | 161 | (.add id-repo (.forSSHAgent keypair)))))
|
161 | 162 |
|
162 | 163 | (and public-key-path private-key-path)
|
163 |
| - (let [id-repo (id-repository)] |
| 164 | + (let [^com.jcraft.jsch.IdentityRepository id-repo (id-repository)] |
164 | 165 | (if (local-repo? id-repo)
|
165 | 166 | (.addIdentity
|
166 | 167 | agent
|
|
172 | 173 | (.add id-repo (.forSSHAgent keypair)))))
|
173 | 174 |
|
174 | 175 | private-key-path
|
175 |
| - (let [id-repo (id-repository)] |
| 176 | + (let [^com.jcraft.jsch.IdentityRepository id-repo (id-repository)] |
176 | 177 | (if (local-repo? id-repo)
|
177 | 178 | (.addIdentity agent (file-path private-key-path) passphrase)
|
178 | 179 | (let [keypair (KeyPair/load agent private-key-path)]
|
@@ -425,7 +426,7 @@ keys. All other option key pairs will be passed as SSH config options."
|
425 | 426 | (Thread/sleep 100))
|
426 | 427 | {:exit (.getExitStatus shell)
|
427 | 428 | :out (if (= :bytes out)
|
428 |
| - (.toByteArray out-stream) |
| 429 | + (.toByteArray ^ByteArrayOutputStream out-stream) |
429 | 430 | (.toString out-stream))}))))
|
430 | 431 |
|
431 | 432 | (defn ssh-exec
|
@@ -464,10 +465,10 @@ keys. All other option key pairs will be passed as SSH config options."
|
464 | 465 | (Thread/sleep 100))
|
465 | 466 | {:exit (.getExitStatus exec)
|
466 | 467 | :out (if (= :bytes out)
|
467 |
| - (.toByteArray out-stream) |
| 468 | + (.toByteArray ^ByteArrayOutputStream out-stream) |
468 | 469 | (.toString out-stream))
|
469 | 470 | :err (if (= :bytes out)
|
470 |
| - (.toByteArray err-stream) |
| 471 | + (.toByteArray ^ByteArrayOutputStream err-stream) |
471 | 472 | (.toString err-stream))}))))
|
472 | 473 |
|
473 | 474 | (defn ssh
|
|
0 commit comments