ControlNode.Host.SSH (Control Node v0.6.0) View Source
Link to this section Summary
Types
SSH spec defines a host which shall be used to connect and deploy releases. Following fields should be defined
Functions
Connect to SSH host
Closes SSH connection to remote host
Execute a given list of command or a bash script on the host VM
Establishes SSH tunnel on given port
i.e. tunnel from localhost:port
to remote_host:port
.
Establishes SSH tunnel on from localhost:local_port
to remote_host:remote_port
Uploads tar_file
to the host
server via SSH and stores it at file_path
on the remote server.
Link to this section Types
Specs
t() :: %ControlNode.Host.SSH{ conn: :ssh.connection_ref(), epmd_port: integer(), host: binary(), hostname: binary(), port: integer(), private_key_dir: binary(), user: binary(), via_ssh_agent: boolean() }
SSH spec defines a host which shall be used to connect and deploy releases. Following fields should be defined
:host
: Remote host uri (eg.server1.somehost.com
):port
: SSH port for connecting to the server (default22
):epmd_port
: Port where EPMD is expected to be running onhost
(default4369
):user
: SSH user name:private_key_dir
: Path to the.ssh
folder (eg./home/user/.ssh
)via_ssh_agent
: Use SSH Agent for authentication (defaultfalse
)
Link to this section Functions
Specs
Connect to SSH host
Closes SSH connection to remote host
Execute a given list of command or a bash script on the host VM
skip_eof
: For commands which start long running processes skip_eof
should
be set to true
. This enable exec
to return ExecStatus
while the command
is left running on host.
Specs
tunnel_port_to_server(t(), :inet.port_number()) :: {:ok, :inet.port_number()} | {:error, any()}
Establishes SSH tunnel on given port
i.e. tunnel from localhost:port
to remote_host:port
.
ssh_config
defines the remote host
Specs
tunnel_port_to_server(t(), :inet.port_number(), :inet.port_number()) :: {:ok, :inet.port_number()} | {:error, any()}
Establishes SSH tunnel on from localhost:local_port
to remote_host:remote_port
ssh_config
defines the remote host
Specs
Uploads tar_file
to the host
server via SSH and stores it at file_path
on the remote server.
file_path
should be absolute path on the remote server.
file_path
is created recursively in case it doesn't exist.
Example
iex> ssh_config = %SSH{host: "remote-host.com", port: 22, user: "username", private_key_dir: "/home/local_user/.ssh"}
iex> ControlNode.Host.SSH.upload_file(ssh_config, "/opt/remote/server/directory", "file_contexts_binary")
:ok