Skip to content

Commit 30b44a2

Browse files
committed
Merge branch 'release/0.5.1'
2 parents 86872c0 + e9e5465 commit 30b44a2

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ A: Probably a disk full, or permission error.
133133
Via [clojars](http://clojars.org) and
134134
[Leiningen](http://github.com/technomancy/leiningen).
135135

136-
:dependencies [clj-ssh "0.5.0"]
136+
:dependencies [clj-ssh "0.5.1"]
137137

138138
or your favourite maven repository aware tool.
139139

ReleaseNotes.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Release Notes
22

3-
Current release is 0.5.0
3+
Current release is 0.5.1
4+
5+
## 0.5.1
6+
7+
- Fix adding key string identities for ssh-agent
8+
Adding string based ssh keys to an ssh-agent was broken.
49

510
## 0.5.0
611

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject clj-ssh "0.5.0"
1+
(defproject clj-ssh "0.5.1"
22
:description "Library for using SSH from clojure."
33
:url "https://github.com/hugoduncan/clj-ssh"
44
:license {:name "Eclipse Public License"

src/clj_ssh/ssh.clj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@
8484
(keyword? arg) (name arg)
8585
:else (str arg)))
8686

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+
8797
(defn ssh-agent?
8898
"Predicate to test for an ssh-agent."
8999
[object] (instance? JSch object))
@@ -149,11 +159,13 @@
149159
identity
150160
(.addIdentity agent identity passphrase)
151161

152-
(and public-key private-key)
162+
private-key
153163
(let [^com.jcraft.jsch.IdentityRepository id-repo (id-repository)]
154164
(if (local-repo? id-repo)
155165
(.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))]
157169
(when passphrase
158170
(.decrypt keypair passphrase))
159171
(.add id-repo (.forSSHAgent keypair)))))

0 commit comments

Comments
 (0)