sshkit v0.0.1 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)
log = fn {type, data} ->
case type do
:normal -> IO.write(data)
:stderr -> IO.write([IO.ANSI.red, data, IO.ANSI.reset])
end
end
Enum.each(output, log)
IO.puts("$?: #{status}")
Summary
Functions
Closes an SSH connection
Establishes a connection to an SSH server
Executes a command on the remote
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.
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
{:normal, data}
or {:stderr, data}
.
A custom handler function can be provided to handle channel messages.
Example
{:ok, output, status} = SSHKit.SSH.run(conn, 'uptime')