Liking cljdoc? Tell your friends :D

clj-ssh.cli

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.
raw docstring

*default-session-options*clj

Default SSH options

Default SSH options
raw docstring

*ssh-agent*clj

SSH agent used to manage identities.

SSH agent used to manage identities.
raw docstring

add-identityclj

(add-identity &
              {:keys [agent name public-key private-key public-key-path
                      private-key-path identity passphrase]
               :or {agent *ssh-agent*}
               :as options})

Add an identity to the agent.

:private-key A string specifying the private key :public-key A string specifying the public key :private-key-path A string specifying a path to the private key :public-key-path A string specifying a path to the public key :identity A jsch Identity object (see make-identity) :passphrase A byte array containing the passphrase

Add an identity to the agent.

:private-key       A string specifying the private key
:public-key        A string specifying the public key
:private-key-path  A string specifying a path to the private key
:public-key-path   A string specifying a path to the public key
:identity          A jsch Identity object (see make-identity)
:passphrase        A byte array containing the passphrase
raw docstring

add-identity-with-keychainclj

(add-identity-with-keychain &
                            {:keys [agent name public-key-path private-key-path
                                    identity passphrase]
                             :or {agent *ssh-agent*}
                             :as options})

Add a private key, only if not already known, using the keychain to obtain a passphrase if required

Add a private key, only if not already known, using the keychain to obtain
a passphrase if required
raw docstring

default-session-optionsclj

(default-session-options options)

Set the default session options

Set the default session options
raw docstring

generate-keypairclj

(generate-keypair key-type key-size passphrase)

Generate a keypair, returned as [private public] byte arrays. Valid types are :rsa and :dsa. key-size is in bytes. passphrase can be a string or byte array.

Generate a keypair, returned as [private public] byte arrays.
Valid types are :rsa and :dsa.  key-size is in bytes. passphrase
can be a string or byte array.
raw docstring

has-identity?clj

(has-identity? name)

Check if the given identity is present.

Check if the given identity is present.
raw docstring

sessionclj

(session hostname
         &
         {:keys [port username agent password]
          :or {agent *ssh-agent* port 22}
          :as options})

Start a SSH session. Requires hostname. you can also pass values for :username, :password and :port keys. All other option key pairs will be passed as SSH config options.

Start a SSH session.
Requires hostname.  you can also pass values for :username, :password and :port
keys.  All other option key pairs will be passed as SSH config options.
raw docstring

sftpclj

(sftp hostname cmd & args)

Execute SFTP commands.

sftp host-or-session cmd & options

cmd specifies a command to exec. Valid commands are: :ls :put :get :chmod :chown :chgrp :cd :lcd :pwd :lpwd :rm :rmdir :stat :symlink

Options are :username username to use for authentication :password password to use for authentication :port port to use if no session specified :with-monitor :modes

Execute SFTP commands.

  sftp host-or-session cmd & options

cmd specifies a command to exec.  Valid commands are:
:ls
:put
:get
:chmod
:chown
:chgrp
:cd
:lcd
:pwd
:lpwd
:rm
:rmdir
:stat
:symlink

Options are
:username   username to use for authentication
:password   password to use for authentication
:port       port to use if no session specified
:with-monitor
:modes
raw docstring

sshclj

(ssh hostname & args)

Execute commands over ssh.

Options are:

:cmd specifies a command to exec. If no cmd is given, a shell is started and input is taken from :in. :in specifies input to the remote shell. A string or a stream.

:out specify :stream to obtain a an [inputstream shell] specify :bytes to obtain a byte array or specify a string with an encoding specification for a result string. In the case of :stream, the shell can be polled for connected status, and the session (in the :session key of the return value) must be disconnected by the caller. :username username to use for authentication :password password to use for authentication :port port to use if no session specified

sh returns a map of :exit => sub-process's exit code :out => sub-process's stdout (as byte[] or String) :err => sub-process's stderr (as byte[] or String)

Execute commands over ssh.

Options are:

:cmd        specifies a command to exec.  If no cmd is given, a shell is started
            and input is taken from :in.
:in         specifies input to the remote shell. A string or a stream.

:out        specify :stream to obtain a an [inputstream shell]
            specify :bytes to obtain a byte array
            or specify a string with an encoding specification for a
            result string.
            In the case of :stream, the shell can be polled for connected
            status, and the session (in the :session key of the return value)
            must be disconnected by the caller.
:username   username to use for authentication
:password   password to use for authentication
:port       port to use if no session specified

sh returns a map of
              :exit => sub-process's exit code
              :out  => sub-process's stdout (as byte[] or String)
              :err  => sub-process's stderr (as byte[] or String)
raw docstring

with-default-session-optionscljmacro

(with-default-session-options options & body)

Set the default session options

Set the default session options
raw docstring

with-ssh-agentcljmacro

(with-ssh-agent agent & body)

Bind an ssh-agent for use as identity manager. An existing agent instance is passed as the first argument.

Bind an ssh-agent for use as identity manager. An existing agent instance is
passed as the first argument.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close