Skip to content

Commit c29257c

Browse files
committed
Merge branch 'release/0.4.1'
2 parents cd44412 + 18a9e37 commit c29257c

File tree

7 files changed

+137
-45
lines changed

7 files changed

+137
-45
lines changed

README.md

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,47 +50,75 @@ the system's ssh-agent, or to clj-ssh's ssh-agent with the appropriate
5050

5151
### Non REPL
5252

53-
The `clj-ssh.ssh` namespace should be using SSH from functional code.
53+
The `clj-ssh.ssh` namespace should be used for SSH from functional code.
5454

5555
```clj
56-
(let [agent (ssh-agent {:use-system-ssh-agent false})]
57-
(add-identity agent "/user/name/.ssh/id_rsa")
56+
(let [agent (ssh-agent {})]
5857
(let [session (session agent "localhost" {:strict-host-key-checking :no})]
5958
(with-connection session
6059
(let [result (ssh session {:in "echo hello"})]
6160
(println (result :out)))
6261
(let [result (ssh session {:cmd "ls"}]
63-
(println (second result))))))
62+
(println (second result)))))))
6463
```
6564

6665
The above example shows using `:in` to pass commands to a shell, and using
6766
`:cmd` to exec a command without a shell. When using `:cmd` you can still pass
6867
a stream or a string to `:in` to be used as the process' standard input.
6968

69+
By default, the system ssh-agent is used, which means the ssh keys you use at
70+
the command line level should automatically be picked up (this should also work
71+
with `pageant` on windows).
72+
73+
You can forward the ssh-agent, which allows you to run ssh based commands on the
74+
remote host using the credentials in your local ssh-agent:
75+
76+
```clj
77+
(let [agent (ssh-agent {})]
78+
(let [session (session agent "localhost" {:strict-host-key-checking :no})]
79+
(with-connection session
80+
(let [result (ssh session {:in "ssh somehost ls" :agent-forwarding true})]
81+
(println (result :out))))))
82+
```
83+
84+
If you prefer not to use the system ssh-agent, or one is not running on your
85+
system, then a local, isolated ssh-agent can be used.
86+
87+
```clj
88+
(let [agent (ssh-agent {:use-system-ssh-agent false})]
89+
(add-identity agent "/user/name/.ssh/id_rsa")
90+
(let [session (session agent "localhost" {:strict-host-key-checking :no})]
91+
(with-connection session
92+
(let [result (ssh session {:in "echo hello"})]
93+
(println (result :out)))))
94+
```
95+
96+
SFTP is supported:
97+
7098
```clj
7199
(let [agent (ssh-agent {})]
72100
(let [session (session agent "localhost" {:strict-host-key-checking :no})]
73101
(with-connection session
74102
(let [channel (ssh-sftp session)]
75103
(with-channel-connection channel
76-
(sftp channel :cd "/remote/path")
77-
(sftp channel :put "/some/file" "filename"))))))
104+
(sftp channel {} :cd "/remote/path")
105+
(sftp channel {} :put "/some/file" "filename"))))))
78106
```
79107

80108
SSH tunneling is also supported:
81109

82110
```clj
83-
(let [agent (ssh-agent {:use-system-ssh-agent false})]
84-
(let [session (session agent "localhost" :strict-host-key-checking :no)]
111+
(let [agent (ssh-agent {})]
112+
(let [session (session agent "localhost" {:strict-host-key-checking :no})]
85113
(with-connection session
86114
(with-local-port-forward [session 8080 80]
87115
(comment do something with port 8080 here)))))
88116
```
89117

90118
## Documentation
91119

92-
[Annotated source](http:/hugoduncan.github.com/clj-ssh/uberdoc.html).
93-
[API](http:/hugoduncan.github.com/clj-ssh/api/0.3/index.html).
120+
[Annotated source](http:/hugoduncan.github.com/clj-ssh/api/0.4/uberdoc.html).
121+
[API](http:/hugoduncan.github.com/clj-ssh/api/0.4/index.html).
94122

95123
## FAQ
96124

@@ -105,7 +133,7 @@ A: Probably a disk full, or permission error.
105133
Via [clojars](http://clojars.org) and
106134
[Leiningen](http://github.com/technomancy/leiningen).
107135

108-
:dependencies [clj-ssh "0.4.0"]
136+
:dependencies [clj-ssh "0.4.1"]
109137

110138
or your favourite maven repository aware tool.
111139

ReleaseNotes.md

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

3-
Current release is 0.4.0
3+
Current release is 0.4.1
4+
5+
## 0.4.1
6+
7+
- add option to ssh-agent for :known-hosts-path. Fixes #16.
8+
9+
- remap log levels to be less verbose by default. Fixes #17
410

511
## 0.4.0
612

brick.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(defbrick clj-ssh
2+
:images {:vmfest [{:image {:os-family :ubuntu :os-version-matches "12.04"
3+
:os-64-bit true}
4+
:selectors [:default]}]})

profiles.clj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{:dev {:dependencies [[ch.qos.logback/logback-classic "1.0.0"]]}
2+
:slingshot-0.10.1 {:dependencies [[slingshot "0.10.1"]
3+
[org.clojure/clojure "1.2.1"]]}
4+
:clojure-1.2.1 {:dependencies [[slingshot "0.10.1"]
5+
[org.clojure/clojure "1.2.1"]]}
6+
:clojure-1.3.0 {:dependencies [[slingshot "0.10.1"]
7+
[org.clojure/clojure "1.3.0"]]}
8+
:clojure-1.4.0 {:dependencies [[slingshot "0.10.1"]
9+
[org.clojure/clojure "1.4.0-beta1"]]}
10+
:codox {:codox {:writer codox-md.writer/write-docs
11+
:version "0.4"
12+
:output-dir "doc/api/0.4"
13+
:exclude [clj-ssh.agent clj-ssh.reflect clj-ssh.keychain]}
14+
:dependencies [[codox-md "0.1.0" :exclusions [org.clojure/clojure]]]}
15+
:marginalia {:marginalia {:dir "doc/api/0.4"}}
16+
:release
17+
{:plugins [[lein-set-version "0.2.1"]]
18+
:set-version
19+
{:updates [{:path "README.md"
20+
:no-snapshot true
21+
:search-regex #"clj-ssh \"\d+\.\d+\.\d+\""}]}}}

project.clj

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
1-
(defproject clj-ssh "0.4.0"
1+
(defproject clj-ssh "0.4.1"
22
:description "Library for using SSH from clojure."
33
:url "https://github.com/hugoduncan/clj-ssh"
4+
:license {:name "Eclipse Public License"
5+
:url "http://www.eclipse.org/legal/epl-v10.html"}
46
:dependencies [[org.clojure/clojure "1.2.1"]
5-
[org.clojure/tools.logging "0.1.2"]
7+
[org.clojure/tools.logging "0.1.2"
8+
:exclusions [org.clojure/clojure]]
69
[jsch-agent-proxy "0.0.4"]
710
[jsch-agent-proxy/jsch-agent-proxy-jna "0.0.4"
811
:exclusions [com.jcraft/jsch-agent-proxy]]
9-
[slingshot "0.10.2"]
10-
[com.jcraft/jsch "0.1.48"]]
11-
:dev-dependencies [[org.slf4j/slf4j-api "1.6.1"]
12-
[ch.qos.logback/logback-core "1.0.0"]
13-
[ch.qos.logback/logback-classic "1.0.0"]]
14-
:profiles {:dev {:dependencies [[org.slf4j/slf4j-api "1.6.1"]
15-
[ch.qos.logback/logback-core "1.0.0"]
16-
[ch.qos.logback/logback-classic "1.0.0"]
17-
[codox-md "0.1.0"]]}}
18-
:multi-deps {"slingshot-0.10.1" [[slingshot "0.10.1"]
19-
[org.clojure/clojure "1.2.1"]]
20-
"clojure-1.2.1" [[slingshot "0.10.1"]
21-
[org.clojure/clojure "1.2.1"]]
22-
"clojure-1.3.0" [[slingshot "0.10.1"]
23-
[org.clojure/clojure "1.3.0"]]
24-
"clojure-1.4.0" [[slingshot "0.10.1"]
25-
[org.clojure/clojure "1.4.0-beta1"]]}
26-
:codox {:writer codox-md.writer/write-docs
27-
:version "0.4"
28-
:output-dir "doc/api/0.4"
29-
:exclude [clj-ssh.agent clj-ssh.reflect clj-ssh.keychain]}
30-
:license {:name "Eclipse Public License"
31-
:url "http://www.eclipse.org/legal/epl-v10.html"})
12+
[slingshot "0.10.2"
13+
:exclusions [org.clojure/clojure]]
14+
[com.jcraft/jsch "0.1.48"]])

release.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
# start the release
4+
5+
if [[ $# -lt 3 ]]; then
6+
echo "usage: $(basename $0) previous-version new-version next-version" >&2
7+
exit 1
8+
fi
9+
10+
previous_version=$1
11+
version=$2
12+
next_version=$3
13+
14+
echo ""
15+
echo "Start release of $version, previous version is $previous_version"
16+
echo ""
17+
echo ""
18+
19+
lein do clean, test && \
20+
git flow release start $version || exit 1
21+
22+
lein with-profile release set-version ${version} :previous-version ${previous_version} \
23+
|| { echo "set version failed" >&2 ; exit 1; }
24+
25+
echo ""
26+
echo ""
27+
echo "Changes since $previous_version"
28+
git log --pretty=changelog $previous_version..
29+
echo ""
30+
echo ""
31+
echo "Now edit ReleaseNotes, README and project.clj"
32+
33+
$EDITOR ReleaseNotes.md
34+
$EDITOR README.md
35+
$EDITOR project.clj
36+
37+
echo -n "commiting release notes and readme. enter to continue:" && read x \
38+
&& git add ReleaseNotes.md README.md project.clj \
39+
&& git commit -m "Updated version, release notes and readme for $version" \
40+
&& echo -n "Peform release. enter to continue:" && read x \
41+
&& lein with-profile default:clojure-1.2.1:clojure-1.3.0:clojure-1.4.0 test \
42+
&& lein deploy clojars \
43+
&& git flow release finish $version \
44+
&& lein with-profile release set-version ${next_version} \
45+
&& git add project.clj \
46+
&& git commit -m "Updated version for next release cycle"

src/clj_ssh/ssh.clj

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
(def ^{:dynamic true}
4646
ssh-log-levels
4747
(atom
48-
{com.jcraft.jsch.Logger/DEBUG :debug
49-
com.jcraft.jsch.Logger/INFO :info
48+
{com.jcraft.jsch.Logger/DEBUG :trace
49+
com.jcraft.jsch.Logger/INFO :debug
5050
com.jcraft.jsch.Logger/WARN :warn
5151
com.jcraft.jsch.Logger/ERROR :error
5252
com.jcraft.jsch.Logger/FATAL :fatal}))
@@ -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?
@@ -536,7 +540,7 @@ sh returns a map of
536540
(defn sftp
537541
"Execute SFTP commands.
538542
539-
sftp host-or-session cmd & options
543+
sftp host-or-session options cmd & args
540544
541545
cmd specifies a command to exec. Valid commands are:
542546
:ls

0 commit comments

Comments
 (0)