ssh_connection(3erl) | Erlang Module Definition | ssh_connection(3erl) |
ssh_connection -
This module provides API functions to send SSH Connection Protocol
events to the other side of an SSH channel.
The SSH Connection Protocol is used by clients and servers, that is, SSH channels, to communicate over the SSH connection. The API functions in this module send SSH Connection Protocol events, which are received as messages by the remote channel. If the receiving channel is an Erlang process, the messages have the format {ssh_cm, connection_ref(), ssh_event_msg()}. If the ssh_client_channel behavior is used to implement the channel process, these messages are handled by handle_ssh_msg/2.
Type definitions that are used more than once in this module, or abstractions to indicate the intended use of the data type, or both:
Events that include a WantReply expect the event handling process to call ssh_connection:reply_request/4 with the boolean value of WantReply as the second argument.
adjust_window(ConnectionRef, ChannelId, NumOfBytes) ->
ok
Types:
Adjusts the SSH flow control window. This is to be done by both the client- and server-side channel processes.
close(ConnectionRef, ChannelId) -> ok
Types:
A server- or client-channel process can choose to close their session by sending a close event.
exec(ConnectionRef, ChannelId, Command, TimeOut) ->
ssh_request_status() | {error, reason()}
Types:
Is to be called by a client-channel process to request that the server starts executing the given command. The result is several messages according to the following pattern. The last message is a channel close message, as the exec request is a one-time execution that closes the channel when it is done.
exit_status(ConnectionRef, ChannelId, Status) -> ok
Types:
Is to be called by a server-channel process to send the exit status of a command to the client.
ptty_alloc(ConnectionRef, ChannelId, Options) ->
ptty_alloc(ConnectionRef, ChannelId, Options, Timeout) -> >
ssh_request_status() | {error, reason()}
Types:
Sends an SSH Connection Protocol pty_req, to allocate a pseudo-terminal. Is to be called by an SSH client process.
Options:
reply_request(ConnectionRef, WantReply, Status, ChannelId)
-> ok
Types:
Sends status replies to requests where the requester has stated that it wants a status report, that is, WantReply = true. If WantReply is false, calling this function becomes a "noop". Is to be called while handling an SSH Connection Protocol message containing a WantReply boolean value.
send(ConnectionRef, ChannelId, Data) ->
send(ConnectionRef, ChannelId, Data, Timeout) ->
send(ConnectionRef, ChannelId, Type, Data) ->
send(ConnectionRef, ChannelId, Type, Data, TimeOut) -> ok | {error,
timeout} | {error, closed}
Types:
Is to be called by client- and server-channel processes to send data to each other.
The function subsystem/4 and subsequent calls of send/3,4,5 must be executed in the same process.
send_eof(ConnectionRef, ChannelId) -> ok | {error,
closed}
Types:
Sends EOF on channel ChannelId.
session_channel(ConnectionRef, Timeout) ->
session_channel(ConnectionRef, InitialWindowSize, MaxPacketSize, Timeout)
-> {ok, channel_id()} | {error, reason()}
Types:
Opens a channel for an SSH session. The channel id returned from this function is the id used as input to the other functions in this module.
setenv(ConnectionRef, ChannelId, Var, Value, TimeOut) ->
ssh_request_status() | {error, reason()}
Types:
Environment variables can be passed before starting the shell/command. Is to be called by a client channel processes.
shell(ConnectionRef, ChannelId) -> ok | failure | {error,
closed}
Types:
Is to be called by a client channel process to request that the user default shell (typically defined in /etc/passwd in Unix systems) is executed at the server end.
Note: the return value is ok instead of success unlike in other functions in this module. This is a fault that was introduced so long ago that any change would break a large number of existing software.
subsystem(ConnectionRef, ChannelId, Subsystem, Timeout) ->
ssh_request_status() | {error, reason()}
Types:
Is to be called by a client-channel process for requesting to execute a predefined subsystem on the server.
The function subsystem/4 and subsequent calls of send/3,4,5 must be executed in the same process.
ssh 4.7.3 | Ericsson AB |