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.
SSH agent used to manage identities.
SSH agent used to manage identities.
(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
(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
(default-session-options options)
Set the default session options
Set the default session options
(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.
(has-identity? name)
Check if the given identity is present.
Check if the given identity is present.
(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.
(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
(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)
(with-default-session-options options & body)
Set the default session options
Set the default session options
(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.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close