Skip to content

Commit e78c2db

Browse files
committed
Update namespace docs
1 parent be32650 commit e78c2db

File tree

3 files changed

+44
-23
lines changed

3 files changed

+44
-23
lines changed

project.clj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(defproject clj-ssh "0.4.0-SNAPSHOT"
22
:description "Library for using SSH from clojure."
3+
:url "https://github.com/hugoduncan/clj-ssh"
34
:dependencies [[org.clojure/clojure "1.2.1"]
45
[org.clojure/tools.logging "0.1.2"]
56
[jsch-agent-proxy "0.0.4"]
@@ -23,4 +24,7 @@
2324
[org.clojure/clojure "1.4.0-beta1"]]}
2425
:codox {:writer codox-md.writer/write-docs
2526
:version "0.4"
26-
:output-dir "doc/api/0.4"})
27+
:output-dir "doc/api/0.4"
28+
:exclude [clj-ssh.agent clj-ssh.reflect clj-ssh.keychain]}
29+
:license {:name "Eclipse Public License"
30+
:url "http://www.eclipse.org/legal/epl-v10.html"})

src/clj_ssh/cli.clj

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
(ns clj-ssh.cli
2-
"Provides a REPL friendly interface for clj-ssh."
2+
"Provides a REPL friendly interface for clj-ssh.
3+
4+
There is a simple `ssh` function, which by default, will use the system
5+
ssh-agent.
6+
7+
(ssh \"hostname\" \"ls\")
8+
9+
Strict host key checking can be turned off.
10+
11+
(default-session-options {:strict-host-key-checking :no})
12+
13+
By default, your current username is used. If your key has a passphrase, and
14+
you are on OSX, then you should be asked for access to your keychain. If you
15+
are on any other OS without a ssh-agent, you will need to explicitly add your
16+
key to the clj-ssh's ssh-agent with the appropriate add-identity call.
17+
18+
SFTP is supported:
19+
20+
(sftp \"hostname\" :put \"/from/this/path\" \"to/this/path\")
21+
22+
Note that any sftp commands that change the state of the sftp session (such as
23+
cd) do not work with the simplified interface, as a new session is created each
24+
time."
325
(:require
426
[clj-ssh.ssh :as ssh]
527
[clojure.string :as string]))
@@ -156,8 +178,7 @@ Options are
156178
:password password to use for authentication
157179
:port port to use if no session specified
158180
:with-monitor
159-
:modes
160-
"
181+
:modes"
161182
[hostname cmd & args]
162183
(let [{:keys [ssh-agent args]
163184
:or {ssh-agent *ssh-agent*}

src/clj_ssh/ssh.clj

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
(ns ^{:author "Hugo Duncan"}
22
clj-ssh.ssh
3-
"SSH in clojure. Uses jsch. Provides a ssh function that tries to look
4-
similar to clojure.contrib.shell/sh.
3+
"API for using SSH in clojure.
54
65
## Usage
76
8-
The top level namespace is `clj-ssh.ssh`
9-
107
(use 'clj-ssh.ssh)
118
12-
(with-ssh-agent (ssh-agent {})
13-
(add-identity {:private-key-path path-to-private-key})
14-
(let [session (session hostname :strict-host-key-checking :no)]
9+
(let [agent (ssh-agent {})]
10+
(add-identity agent {:private-key-path path-to-private-key})
11+
(let [session (session agent hostname :strict-host-key-checking :no)]
1512
(with-connection session
16-
(let [result (ssh session :in commands-string :result-map true)]
17-
(println (result :out)))
18-
(let [result (ssh session some-cmd-string)]
19-
(println (second result))))))
20-
21-
## Installation
22-
23-
Via maven and the clojars (http://clojars.org/clj-ssh), or
24-
Leiningen (http://github.com/technomancy/leiningen).
13+
(let [result (ssh session {:in commands-string})]
14+
(println (:out result)))
15+
(let [result (ssh session {:cmd some-cmd-string})]
16+
(println (:out result))))))
2517
26-
## License
27-
28-
Licensed under EPL (http://www.eclipse.org/legal/epl-v10.html)"
18+
(let [agent (ssh-agent {})]
19+
(let [session (session agent \"localhost\" {:strict-host-key-checking :no})]
20+
(with-connection session
21+
(let [channel (ssh-sftp session)]
22+
(with-channel-connection channel
23+
(sftp channel :cd \"/remote/path\")
24+
(sftp channel :put \"/some/file\" \"filename\"))))))"
2925
(:require
3026
[clj-ssh.agent :as agent]
3127
[clj-ssh.keychain :as keychain]

0 commit comments

Comments
 (0)