Skip to content

Commit adbca58

Browse files
committed
Improve cli doc
1 parent d37b8e8 commit adbca58

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,34 @@ The `clj-ssh.cli` namespace provides some functions for ease of use at the REPL.
1010

1111
(use 'clj-ssh.ssh)
1212

13-
There is a simple `ssh` function, which by default, will use the system
14-
ssh-agent.
13+
Use `ssh` to execute a command, say `ls`, on a remote host \"my-host\",
1514

16-
(ssh "hostname" "ls")
15+
(ssh \"my-host\" \"ls\")
16+
=> {:exit 0 :out \"file1\\nfile2\\n\" :err \"\")
1717

18-
Strict host key checking can be turned off.
18+
By default this will use the system ssh-agent to obtain your ssh keys, and it
19+
uses your current username, but this can be specified:
1920

20-
(default-session-options {:strict-host-key-checking :no})
21+
(ssh \"my-host\" \"ls\" :username \"remote-user\")
22+
=> {:exit 0 :out \"file1\\nfile2\\n\" :err \"\")
2123

22-
By default, your current username is used. If your key has a passphrase, and
23-
you are on OSX, then you should be asked for access to your keychain. If you
24-
are on any other OS without a ssh-agent, you will need to explicitly add your
25-
key to the clj-ssh's ssh-agent with the appropriate add-identity call.
24+
Strict host key checking can be turned off:
2625

27-
SFTP is supported:
26+
(default-session-options {:strict-host-key-checking :no})
2827

29-
```clj
30-
(sftp "hostname" :put "/from/this/path" "to/this/path")
31-
```
28+
SFTP is also supported. For example, to copy a local file to a remote host
29+
\"my-host\":
30+
31+
(sftp \"my-host\" :put \"/from/this/path\" \"to/this/path\")
3232

3333
Note that any sftp commands that change the state of the sftp session (such as
3434
cd) do not work with the simplified interface, as a new session is created each
3535
time.
3636

37+
If your key has a passphrase, you will need to explicitly add your key either to
38+
the system's ssh-agent, or to clj-ssh's ssh-agent with the appropriate
39+
`add-identity` call.
40+
3741
### Non REPL
3842

3943
The `clj-ssh.ssh` namespace should be using SSH from functional code.

src/clj_ssh/cli.clj

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
(ns clj-ssh.cli
22
"Provides a REPL friendly interface for clj-ssh.
33
4-
There is a simple `ssh` function, which by default, will use the system
5-
ssh-agent.
4+
(use 'clj-ssh.cli)
65
7-
(ssh \"hostname\" \"ls\")
6+
Use `ssh` to execute a command, say `ls`, on a remote host \"my-host\",
87
9-
Strict host key checking can be turned off.
8+
(ssh \"my-host\" \"ls\")
9+
=> {:exit 0 :out \"file1\\nfile2\\n\" :err \"\")
1010
11-
(default-session-options {:strict-host-key-checking :no})
11+
By default this will use the system ssh-agent to obtain your ssh keys, and it
12+
uses your current username, but this can be specified:
13+
14+
(ssh \"my-host\" \"ls\" :username \"remote-user\")
15+
=> {:exit 0 :out \"file1\\nfile2\\n\" :err \"\")
1216
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+
Strict host key checking can be turned off:
1718
18-
SFTP is supported:
19+
(default-session-options {:strict-host-key-checking :no})
1920
20-
(sftp \"hostname\" :put \"/from/this/path\" \"to/this/path\")
21+
SFTP is also supported. For example, to copy a local file to a remote host
22+
\"my-host\":
23+
24+
(sftp \"my-host\" :put \"/from/this/path\" \"to/this/path\")
2125
2226
Note that any sftp commands that change the state of the sftp session (such as
2327
cd) do not work with the simplified interface, as a new session is created each
24-
time."
28+
time.
29+
30+
If your key has a passphrase, you will need to explicitly add your key either to
31+
the system's ssh-agent, or to clj-ssh's ssh-agent with the appropriate
32+
`add-identity` call."
2533
(:require
2634
[clj-ssh.ssh :as ssh]
2735
[clojure.string :as string]))

0 commit comments

Comments
 (0)