File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 84
84
(keyword? arg) (name arg)
85
85
:else (str arg)))
86
86
87
+ (def ^java.nio.charset.Charset ascii
88
+ (java.nio.charset.Charset/forName " US-ASCII" ))
89
+
90
+ (defn- ^{:tag (Class/forName " [B" )} as-bytes
91
+ " Return arg as a byte array. arg must be a string or a byte array."
92
+ [arg]
93
+ (if (string? arg)
94
+ (.getBytes ^String arg ascii)
95
+ arg))
96
+
87
97
(defn ssh-agent?
88
98
" Predicate to test for an ssh-agent."
89
99
[object] (instance? JSch object))
149
159
identity
150
160
(.addIdentity agent identity passphrase)
151
161
152
- ( and public-key private-key)
162
+ private-key
153
163
(let [^com.jcraft.jsch.IdentityRepository id-repo (id-repository )]
154
164
(if (local-repo? id-repo)
155
165
(.addIdentity agent name private-key public-key passphrase)
156
- (let [keypair (KeyPair/load agent private-key-path public-key-path)]
166
+ (let [^KeyPair keypair
167
+ (KeyPair/load
168
+ agent (as-bytes private-key) (as-bytes public-key))]
157
169
(when passphrase
158
170
(.decrypt keypair passphrase))
159
171
(.add id-repo (.forSSHAgent keypair)))))
You can’t perform that action at this time.
0 commit comments