Agent integration (using jsch-agent-proxy)
Agent integration (using jsch-agent-proxy)
Provides a REPL friendly interface for clj-ssh.
(use 'clj-ssh.cli)
Use ssh
to execute a command, say ls
, on a remote host "my-host",
(ssh "my-host" "ls")
=> {:exit 0 :out "file1\nfile2\n" :err "")
By default this will use the system ssh-agent to obtain your ssh keys, and it uses your current username, but this can be specified:
(ssh "my-host" "ls" :username "remote-user")
=> {:exit 0 :out "file1\nfile2\n" :err "")
Strict host key checking can be turned off:
(default-session-options {:strict-host-key-checking :no})
SFTP is also supported. For example, to copy a local file to a remote host "my-host":
(sftp "my-host" :put "/from/this/path" "to/this/path")
Note that any sftp commands that change the state of the sftp session (such as cd) do not work with the simplified interface, as a new session is created each time.
If your key has a passphrase, you will need to explicitly add your key either to
the system's ssh-agent, or to clj-ssh's ssh-agent with the appropriate
add-identity
call.
Provides a REPL friendly interface for clj-ssh. (use 'clj-ssh.cli) Use `ssh` to execute a command, say `ls`, on a remote host "my-host", (ssh "my-host" "ls") => {:exit 0 :out "file1\nfile2\n" :err "") By default this will use the system ssh-agent to obtain your ssh keys, and it uses your current username, but this can be specified: (ssh "my-host" "ls" :username "remote-user") => {:exit 0 :out "file1\nfile2\n" :err "") Strict host key checking can be turned off: (default-session-options {:strict-host-key-checking :no}) SFTP is also supported. For example, to copy a local file to a remote host "my-host": (sftp "my-host" :put "/from/this/path" "to/this/path") Note that any sftp commands that change the state of the sftp session (such as cd) do not work with the simplified interface, as a new session is created each time. If your key has a passphrase, you will need to explicitly add your key either to the system's ssh-agent, or to clj-ssh's ssh-agent with the appropriate `add-identity` call.
Primitive keychain support for clj-ssh. Only implemented on OSX at the moment.
Primitive keychain support for clj-ssh. Only implemented on OSX at the moment.
API for using SSH in clojure.
(use 'clj-ssh.ssh)
(let [agent (ssh-agent {})]
(add-identity agent {:private-key-path path-to-private-key})
(let [session (session agent hostname :strict-host-key-checking :no)]
(with-connection session
(let [result (ssh session {:in commands-string})]
(println (:out result)))
(let [result (ssh session {:cmd some-cmd-string})]
(println (:out result))))))
(let [agent (ssh-agent {})]
(let [session (session agent "localhost" {:strict-host-key-checking :no})]
(with-connection session
(let [channel (ssh-sftp session)]
(with-channel-connection channel
(sftp channel :cd "/remote/path")
(sftp channel :put "/some/file" "filename"))))))
API for using SSH in clojure. ## Usage (use 'clj-ssh.ssh) (let [agent (ssh-agent {})] (add-identity agent {:private-key-path path-to-private-key}) (let [session (session agent hostname :strict-host-key-checking :no)] (with-connection session (let [result (ssh session {:in commands-string})] (println (:out result))) (let [result (ssh session {:cmd some-cmd-string})] (println (:out result)))))) (let [agent (ssh-agent {})] (let [session (session agent "localhost" {:strict-host-key-checking :no})] (with-connection session (let [channel (ssh-sftp session)] (with-channel-connection channel (sftp channel :cd "/remote/path") (sftp channel :put "/some/file" "filename"))))))
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close