sshkit v0.0.2 SSHKit.SSH
Provides convenience functions for working with SSH connections and executing commands on remote hosts.
Examples
{:ok, conn} = SSHKit.SSH.connect("eg.io", user: "me")
{:ok, output, status} = SSHKit.SSH.run(conn, "uptime")
:ok = SSHKit.SSH.close(conn)
Enum.each(output, fn
{:stdout, data} -> IO.write(data)
{:stderr, data} -> IO.write([IO.ANSI.red, data, IO.ANSI.reset])
end)
IO.puts("$?: #{status}")
Summary
Functions
Closes an SSH connection
Establishes a connection to an SSH server
Executes a command on the remote and aggregates incoming messages
Functions
Closes an SSH connection.
Uses SSHKit.SSH.Connection.close/1 to close the connection.
Example
:ok = SSHKit.SSH.close(conn)
Establishes a connection to an SSH server.
Uses SSHKit.SSH.Connection.open/2 to open a connection.
Example
{:ok, conn} = SSHKit.SSH.connect("eg.io", port: 2222, user: "me", timeout: 1000)
Executes a command on the remote and aggregates incoming messages.
Using the default handler, returns {:ok, output, status} or {:error,
reason}. By default, command output is captured into a list of tuples of the
form {:stdout, data} or {:stderr, data}.
A custom handler function can be provided to handle channel messages.
For further details on handling incoming messages,
see SSHKit.SSH.Channel.loop/4.
Options
:timeout- maximum wait time between messages, defautls to:infinity:fun- handler function passed toSSHKit.SSH.Channel.loop/4:acc- initial accumulator value used in the loop
Example
{:ok, output, status} = SSHKit.SSH.run(conn, "uptime")
IO.inspect(output)