From ac4107ceea994f028ae67b43dbe6676b9ccf2b3b Mon Sep 17 00:00:00 2001
From: tmanevik SSH is a protocol for secure remote logon and
+ other secure network services over an insecure network. Secure Shell (SSH) is a protocol for secure remote login and
- other secure network services over an insecure network. SSH
- provides a single, full-duplex, byte-oriented connection between
+ SSH provides a single, full-duplex, and byte-oriented connection between
client and server. The protocol also provides privacy, integrity,
- server authentication and man-in-the-middle protection. The Erlang SSH application is an implementation of the SSH
- protocol in Erlang which offers API functions to write customized
- SSH clients and servers as well as making the Erlang shell
- available via SSH. Also included in the SSH application are an
- SFTP (SSH File Transfer Protocol) client
The
It is assumed that the reader is familiar with the concepts of
It is assumed that the reader is familiar with the Erlang programming language, + concepts of OTP, and has a basic understanding of public keys.
+Conceptually, the SSH protocol can be partitioned into four + layers:
+ +The SSH Transport Protocol is a secure, low-level transport.
+ It provides strong encryption, cryptographic host
+ authentication, and integrity protection. A minimum of
+ Message Authentication Code (MAC) and encryption
+ algorithms are supported. For details, see the
+
The SSH Authentication Protocol is a general-purpose user
+ authentication protocol run over the SSH Transport Layer
+ Protocol. The
Several configuration options for
+ authentication handling are available in
+
+ The public key handling can be customized by implementing
+ the following behaviours from
The SSH Connection Protocol provides application-support
+ services over the transport pipe, for example, channel multiplexing,
+ flow control, remote program execution, signal propagation, and
+ connection forwarding. Functions for handling the SSH
+ Connection Protocol can be found in the module
All terminal sessions, forwarded connections, and so on, are
+ channels. Multiple channels are multiplexed into a single
+ connection. All channels are flow-controlled. This means that no
+ data is sent to a channel peer until a message is received to
+ indicate that window space is available.
+ The initial window size specifies how many bytes of channel
+ data that can be sent to the channel peer without adjusting the
+ window. Typically, an SSH client opens a channel, sends data (commands),
+ receives data (control information), and then closes the channel.
+ The
Channels come in the following three flavors:
+ ++ For detailed information about the SSH protocol, refer to the + following Request for Comments(RFCs): +
+ +The SSH application is an erlang implementation of the - secure shell protocol (SSH) as defined by RFC 4250 - 4254
+The
Interface module for the SSH application.
+Interface module for the
Type definitions that are used more than once in - this module and/or abstractions to indicate the intended use of the data - type:
-=
=
Opaque to the user,
+ returned by
Opaque to the user,
+ returned by
=
=
=
=
Connects to an SSH server. No channel is started. This is done
by calling
-
Options are:
+Options:
IP version to use.
+Sets the user directory i.e. the directory containing - ssh configuration files for the user such as +
Sets the user directory, that is, the directory containing
+
If the user dsa key is protected by a passphrase it can be +
If the user DSA key is protected by a passphrase, it can be supplied with this option.
If the user rsa key is protected by a passphrase it can be +
If the user RSA key is protected by a passphrase, it can be supplied with this option.
When true hosts are added to the +
When
If false disables the client to connect to the server
- if any user interaction is needed such as accepting that
- the server will be added to the
If
Sets the preferred public key algorithm to use for user
- authentication. If the the preferred algorithm fails for
- some reason, the other algorithm is tried. The default is
+ authentication. If the preferred algorithm fails,
+ the other algorithm is tried. The default is
to try
List of public key algorithms to try to use, 'ssh-rsa' and 'ssh-dss' available.
- Will override
List of public key algorithms to try to use.
+
Sets a timeout on the transport layer +
Sets a time-out on the transport layer
connection. Defaults to
Provides a user name. If this option is not given, ssh +
Provides a username. If this option is not given,
Provide a password for password authentication. If - this option is not given, the user will be asked for a - password if the password authentication method is +
Provides a password for password authentication. + If this option is not given, the user is asked for a + password, if the password authentication method is attempted.
Module implementing the behaviour
Module implementing the behaviour
+
If true, the client will not print out anything on authorization.
+If
Allow an existing file descriptor to be used - (simply passed on to the transport protocol).
Allows an existing file descriptor to be used + (by passing it on to the transport protocol).
Provide, in bytes, when rekeying should be initiated, - defaults to one time each GB and one time per hour.
+Provides, in bytes, when rekeying is to be initiated. + Defaults to once per each GB and once per hour.
Sets a timeout on connection when no channels are active, default is infinity
Sets a time-out on a connection when no channels are active.
+ Defaults to
Retrieves information about a connection. -
+Retrieves information about a connection.
Starts a server listening for SSH connections on the given port.
-Options are:
+Options:
IP version to use when the host address is specified as
Provides specifications for handling of subsystems. The
+ "sftp" subsystem specification is retrieved by calling
+
Defines the read-eval-print loop used when a shell is
+ requested by the client. The default is to use the Erlang shell:
+
Provides your own CLI implementation, that is, a channel callback
+ module that implements a shell and command execution. The shell
+ read-eval-print loop can be customized, using the
+ option
Sets the user directory i.e. the directory containing - ssh configuration files for the user such as +
Sets the user directory. That is, the directory containing
+
Sets the system directory, containing the host key files
- that identifies the host keys for ssh. The default is
-
Comma separated string that determines which - authentication methodes that the server should support and - in what order they will be tried. Defaults to +
Comma-separated string that determines which
+ authentication methods that the server is to support and
+ in what order they are tried. Defaults to
Provide passwords for password authentication.They will - be used when someone tries to connect to the server and - public key user authentication fails. The option provides - a list of valid user names and the corresponding password. +
Provides passwords for password authentication. The passwords + are used when someone tries to connect to the server and + public key user-authentication fails. The option provides + a list of valid usernames and the corresponding passwords.
Provide a global password that will authenticate any +
Provides a global password that authenticates any user. From a security perspective this option makes the server very vulnerable.
Provide a function for password validation. This is called - with user and password as strings, and should return +
Provides a function for password validation. This function is called
+ with user and password as strings, and returns
Max time in milliseconds for the authentication negotiation. The default value is 2 minutes. If the client fails to login within this time, the connection is closed. +
Maximum time in milliseconds for the authentication negotiation. + Defaults to 120000 (2 minutes). If the client fails to log in within this time, + the connection is closed.
The maximum number of simultaneous sessions that are accepted at any time for this daemon. This includes sessions that are being authorized. So if set to
The maximum number of simultaneous sessions that are accepted at any time
+ for this daemon. This includes sessions that are being authorized.
+ Thus, if set to
The counter is per listening port, so if two daemons are started, one with
The counter is per listening port. Thus, if two daemons are started, one with
+
Note that if
Notice that if
As default, the option is not set. This means that the number is not limited. +
By default, this option is not set. This means that the number is not limited.
If set to false (the default value), only one login is handled a time. If set to true, an unlimited number of login attempts will be allowed simultanously. +
If set to false (the default value), only one login is handled at a time. + If set to true, an unlimited number of login attempts are allowed simultaneously.
-If the
If the
Do not enable
Do not enable
Module implementing the behaviour
Module implementing the behaviour
+
Allow an existing file-descriptor to be used - (simply passed on to the transport protocol).
Allows an existing file-descriptor to be used + (passed on to the transport protocol).
+Provide a fun to implement your own logging when a user fails to authenticate.
+Provides a fun to implement your own logging when a user fails to authenticate.
Provide a fun to implement your own logging when a user authenticates to the server.
+Provides a fun to implement your own logging when a user authenticates to the server.
Provide a fun to implement your own logging when a user disconnects from the server.
+Provides a fun to implement your own logging when a user disconnects from the server.
Starts an interactive shell via an SSH server on the +
Starts an interactive shell over an SSH server on the
given
Utility function that starts crypto, public_key and the SSH
- application. Defult type is temporary.
- See also
Utility function that starts the applications
Stops the SSH application. See also
-
Stops the
Stops the listener, but leaves existing connections started - by the listener up and running.
+ by the listener operational.The
The ssh application uses the Erlang applications public_key and - crypto to handle public keys and encryption, hence these - applications needs to be loaded for the ssh application to work. In - an embedded environment that means they need to be started with - application:start/[1,2] before the ssh application is started. +
The
The ssh application does not currently have an application
- specific configuration file as described in application(3),
- however it will by default use the following configuration files
- from openssh: known_hosts, authorized_keys, authorized_keys2,
- id_dsa and id_rsa, ssh_host_dsa_key and ssh_host_rsa_key. By
- default Erlang SSH will look for id_dsa, id_rsa, known_hosts
- and authorized_keys in ~/.ssh, and the host key files in /etc/ssh
- . These locations may be changed by the options user_dir and
- system_dir. Public key handling may also be customized by
- providing a callback module implementing the behaviors
-
The
By default,
Public key handling can also be customized through a callback module that
+ implements the behaviors
+
- id_dsa and id_rsa are the users private key files, note that - the public key is part of the private key so the ssh - application will not use the id_<*>.pub files. These are - for the users convenience when he/she needs to convey their +
The known_hosts file contains a list of approved servers and - their public keys. Once a server is listed, it can be verified +
The
The authorized key file keeps track of the user's authorized +
The
Currently rsa and dsa host keys are supported and are - expected to be found in files named ssh_host_rsa_key and - ssh_host_dsa_key. +
RSA and DSA host keys are supported and are
+ expected to be found in files named
The
SSH services (clients and servers) are implemented as channels
- that are multiplexed over an SSH connection and communicates via
+ that are multiplexed over an SSH connection and communicates over
the
When implementing a SSH subsystem use the
-
When implementing an
Type definitions that are used more than once in this module - and/or abstractions to indicate the intended use of the data - type:
+Type definitions that are used more than once in this module, + or abstractions to indicate the intended use of the data + type, or both:
-=
= list of ASCII characters
=
Opaque to the user, returned by
+
=
=
Makes a synchronous call to the channel process by sending
- a message and waiting until a reply arrives or a timeout
- occurs. The channel will call
Sends an asynchronous message to the channel process and
returns ok immediately, ignoring if the destination node or
- channel process does not exist. The channel will call
+ channel process does not exist. The channel calls
Makes an existing process an
Makes an existing process an
@@ -144,48 +160,47 @@
The module that implements the channel behaviour.
The list of arguments to the
Reference to the
Id of the
This function is normally not called by the
- user. The user only needs to call if for some reason the
+ user. The user only needs to call if the
channel process needs to be started with help of
This function can be used by a channel to explicitly send a +
This function can be used by a channel to send a
reply to a client that called
Starts a processes that handles an SSH channel. It will be
- called internally by the SSH daemon or explicitly by the SSH
- client implementations. The behavior will set the
-
Starts a process that handles an SSH channel. It is
+ called internally, by the
The timeout values that may be returned by the callback functions
- has the same semantics as in a
The time-out values that can be returned by the callback functions
+ have the same semantics as in a
Converts process state when code is changed.
+Converts process state when code is changed.
-This function is called by a client side channel when it
- should update its internal state during a release
- upgrade/downgrade, i.e. when the instruction
-
This function is called by a client-side channel when it
+ is to update its internal state during a release
+ upgrade or downgrade, that is, when the instruction
+
Soft upgrade according to the OTP release concept is not straight forward for the server side, as subsystem - channel processes are spawned by the SSH application and - hence added to its supervisor tree. It could be possible to - upgrade the subsystem channels, when upgrading the user - application, if the callback functions can handle two - versions of the state, but this function can not be used in - the normal way.
+ channel processes are spawned by theMakes necessary initializations and returns the initial channel +
Makes necessary initializations and returns the initial channel state if the initializations succeed.
-For more detailed information on timeouts see the section
-
For more detailed information on time-outs, see Section
+
Handles messages sent by calling
For more detailed information on timeouts see the section
-
For more detailed information on time-outs,, see Section
+
Handles messages sent by calling
-
Handles messages sent by calling
+
For more detailed information on timeouts see the section
-
For more detailed information on time-outs, see Section
+
Handle other messages than ssh connection protocol, call or +
Handles other messages than SSH Connection Protocol, call, or cast messages sent to the channel.
-Possible erlang 'EXIT'-messages should be handled by this - function and all channels should handle the following message.
+Possible Erlang 'EXIT' messages is to be handled by this + function and all channels are to handle the following message.
This is the first message that the channel receives.
+ It is sent just before the
Handles SSH connection protocol messages that may need - service specific attention. +
Handles SSH Connection Protocol messages that may need
+ service-specific attention. For details,
+ see
The following message is completely taken care of by the - SSH channel behavior
+The following message is taken care of by the
+
The channel behavior sends a close message to the
+ other side, if such a message has not already been sent.
+ Then it terminates the channel with reason
This function is called by a channel process when it is
- about to terminate. Before this function is called
Behavior describing the API for an SSH client's public key handling.
- By implementing the callbacks defined.
- in this behavior it is possible to customize the SSH client's public key
- handling. By default the SSH application implements this behavior
- with help of the standard openssh files, see
Behavior describing the API for public key handling of an SSH client. By implementing
+ the callbacks defined in this behavior, the public key handling of an SSH client can
+ be customized. By default the
Type definitions that are used more than once in this module
- and/or abstractions to indicate the intended use of the data
- type. For more details on public key data types
- see the
Type definitions that are used more than once in this module,
+ or abstractions to indicate the intended use of the data
+ type, or both. For more details on public key data types,
+ refer to Section 2 Public Key Records in the
+
boolean() = true | false
-string() = [byte()]
-public_key() = #'RSAPublicKey'{}| {integer(), #'Dss-Parms'{}}| term()
-private_key() = #'RSAPrivateKey'{} | #'DSAPrivateKey'{} | term()
-public_key_algorithm() = 'ssh-rsa'| 'ssh-dss' | atom()
- +=
=
=
=
=
Adds a host key to the set of trusted host keys
+Adds a host key to the set of trusted host keys.
Checks if a host key is trusted
+Checks if a host key is trusted.
Fetches the users "public key" matching the The private key contains the public key
Fetches the users public key matching the
The private key contains the public key.
The SSH Connection Protocol is used by clients and servers
- (i.e. SSH channels) to communicate over the SSH connection. The
- API functions in this module sends SSH Connection Protocol events
- that are received as messages by the remote channel.
- In the case that the receiving channel is an Erlang process the
- message will be on the following format
-
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
+
Type definitions that are used more than once in this module and/or - abstractions to indicate the intended use of the data type:
- -Type definitions that are used more than once in this module, + or abstractions to indicate the intended use of the data + type, or both:
+ +=
= list of ASCII characters
=
Opaque to the user, returned by
+
=
=
=
=
=
=
Data has arrived on the channel. This event is sent as a
+ result of calling
Indicates that the other side sends no more data.
+ This event is sent as a result of calling
A signal can be delivered to the remote process/service + using the following message. Some systems do not support + signals, in which case they are to ignore this message. There is + currently no function to generate this event as the signals + referred to are on OS-level and not something generated by an + Erlang program.
A remote execution can terminate violently because of a signal.
+ Then this message can be received. For details on valid string
+ values, see
When the command running at the other end terminates, the
following message can be sent to return the exit status of the
- command. A zero 'exit_status' usually means that the command
- terminated successfully. This event is sent as result of calling
+ command. A zero
This event is sent as a result of calling
+
Channels implementing a shell and command execution on the - server side should handle the following messages that may be sent by client channel processes.
+Channels implementing a shell and command execution on the + server side are to handle the following messages that can be sent by client- + channel processes.
-Events that includes a
Events that include a
Environment variables can be passed to the shell/command
+ to be started later. This event is sent as a result of calling
A pseudo-terminal has been requested for the
+ session.
This message requests that the user default shell
+ is started at the other end. This event is sent as a result of calling
+
When the window (terminal) size changes on the client + side, it can send a message to the server side to inform it of + the new dimensions. No API function generates this event.
This message requests that the server starts
+ execution of the given command. This event is sent as a result of calling
Adjusts the SSH flowcontrol window. This shall be done by both client and server side channel processes.
+Adjusts the SSH flow control window. This is to be done by both the + client- and server-side channel processes.
-Channels implemented with the Channels implemented with the
A server or client channel process can choose to close their session by sending a close event. +
A server- or client-channel process can choose to close their session by + sending a close event.
-This function will be called by the ssh_channel
- behavior when the channel is terminated see
This function is called by the
Should be called by a client channel process to request that the server starts execution of the - given command, the result will be several messages according to the following pattern. Note - that the last message will be a channel close message, as the exec request is a one time - execution that closes the channel when it is done.
+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
The result of executing the command can be only one line + or thousands of lines depending on the command.
Indicates that no more data is to be sent.
Not all systems send signals. For details on valid string + values, see RFC 4254, Section 6.10
It is recommended by the SSH Connection Protocol to send this + message, but that is not always the case.
Indicates that the
Should be called by a server channel process to sends the exit status of a command to the client.
+Is to be called by a server-channel process to send the exit status of a command + to the client.
Sends a SSH Connection Protocol pty_req, to allocate a pseudo tty. - Should be called by a SSH client process. - Options are: -
+Sends an SSH Connection Protocol
Options:
Defaults to os:getenv("TERM") or vt100 + if it is undefined.
Defaults to 80 if
Defaults to 24 if
Is disregarded if
Is disregarded if
Option can be an empty list. Otherwise, see possible POSIX names
+ in Section 8 in
Sends status replies to requests where the requester has
- stated that they want a status report e.i .
Should be called by client- and server channel processes to send data to each other. +
Is to be called by client- and server-channel processes to send data to each other.
Sends eof on the channel
Sends EOF on channel
Opens a channel for an SSH session. The channel id returned from this function - is the id used as input to the other funtions in this module. -
+ is the id used as input to the other functions in this module.Environment variables may be passed before starting the - shell/command. Should be called by a client channel processes. -
+Environment variables can be passed before starting the + shell/command. Is to be called by a client channel processes.
Should be called by a client channel process to request that the user's default shell (typically - defined in /etc/passwd in UNIX systems) shall be executed at the server end. -
+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.
Should be called by a client channel process for requesting to execute a predefined subsystem on the server. +
Is to be called by a client-channel process for requesting to execute a predefined + subsystem on the server.
Behaviour describing the API for an SSH server's public key handling. By implementing the callbacks defined
- in this behavior it is possible to customize the SSH server's public key
- handling. By default the SSH application implements this behavior
- with help of the standard openssh files, see
Behaviour describing the API for public key handling of an SSH server. By implementing
+ the callbacks defined in this behavior, the public key handling of an SSH server can
+ be customized. By default the SSH application implements this behavior
+ with help of the standard OpenSSH files,
+ see the
Type definitions that are used more than once in this module
- and/or abstractions to indicate the intended use of the data
- type. For more details on public key data types
- see the
Type definitions that are used more than once in this module,
+ or abstractions to indicate the intended use of the data
+ type, or both. For more details on public key data types,
+ refer to Section 2 Public Key Records in the
+
boolean() = true | false
-string() = [byte()]
-public_key() = #'RSAPublicKey'{} | {integer(), #'Dss-Parms'{}} | term()
-private_key() = #'RSAPrivateKey'{} | #'DSAPrivateKey'{} | term()
-public_key_algorithm() = 'ssh-rsa' | 'ssh-dss' | atom()
+=
=
=
=
=
Fetches the hosts private key
+Fetches the private key of the host.
Checks if the user key is authorized
+Checks if the user key is authorized.
This module implements an SFTP (SSH FTP) client. SFTP is a +
This module implements an SSH FTP (SFTP) client. SFTP is a secure, encrypted file transfer service available for SSH.
Type definitions that are used more than once in this module - and/or abstractions to indicate the intended use of the data type: +
Type definitions that are used more than once in this module, + or abstractions to indicate the intended use of the data type, or both:
-Opaque to the user, returned by
=
If the request functions for the SFTP channel return {error, timeout} - it does not guarantee that the request did not reach the server and was - not performed, it only means that we did not receive an answer from the - server within the time that was expected.
+If the request functions for the SFTP channel return
If no connection reference is provided, a connection is set
- up and the new connection is returned. An SSH channel process
+ up, and the new connection is returned. An SSH channel process
is started to handle the communication with the SFTP server.
- The returned pid for this process should be used as input to
+ The returned
Options are:
+Options:
The timeout is passed to the ssh_channel start function, - and defaults to infinity.
+The time-out is passed to the
Desired SFTP protocol version. - The actual version will be the minimum of + The actual version is the minimum of the desired version and the maximum supported versions by the SFTP server.
All other options are directly passed to +
All other options are directly passed to
Stops an SFTP channel. Does not close the SSH connetion. +
Stops an SFTP channel. Does not close the SSH connection.
Use
Writes a file to the server, like
-
Opens a file on the server, and returns a handle that +
Opens a file on the server and returns a handle, which can be used for reading or writing.
Opens a handle to a directory on the server, the handle +
Opens a handle to a directory on the server. The handle can be used for reading directory contents.
Opens a handle to a tar file on the server associated with
Opens a handle to a tar file on the server, associated with
An example of writing and then reading a tar file:
+Example of writing and then reading a tar file follows:
{ok,HandleWrite} = ssh_sftp:open_tar(ChannelPid, ?tar_file_name, [write]),
ok = erl_tar:add(HandleWrite, .... ),
@@ -238,25 +245,24 @@
ok = erl_tar:close(HandleRead),
- The
The
The
The
The write and read example above can be extended with encryption and decryption:
+The previous write and read example can be extended with encryption and decryption as follows:
%% First three parameters depending on which crypto type we select:
Key = <<"This is a 256 bit key. abcdefghi">>,
@@ -307,9 +313,9 @@
If the file is read past eof, only the remaining bytes
- will be read and returned. If no bytes are read,
If the file is read past
The
Reads from an open file, without waiting for the result. If the
- handle is valid, the function returns
The
Writes
Writes
Typical error reasons are:
+Typical error reasons:
The file is not opened for writing.
+File is not opened for writing.
There is a no space left on the device.
+No space is left on the device.
Writes to an open file, without waiting for the result. If the
- handle is valid, the function returns
The
The same as above with
The same as eariler with
Returns a
Renames a file named
Renames a file named
Deletes the file specified by
Creates a directory specified by
Creates a directory specified by
Deletes a directory specified by
Specifies a channel process to handle a sftp subsystem.
+Specifies a channel process to handle an SFTP subsystem.
=
=
=
=
Should be used together with ssh:daemon/[1,2,3]
-Options are:
+Is to be used together with
Options:
Sets the initial current working directory for the - server.
+Sets the initial current working directory for the server.
Determines which module to call for accessing
- the file server. The default value is
The default value is
Sets the sftp root directory. The user will then not be
- able to see any files above this root. If for instance
- the root is set to
Sets the SFTP root directory. Then the user cannot see any files
+ above this root. If, for example, the root directory is set to
Sets the sftp version to use, defaults to 5. Version 6 is under +
Sets the SFTP version to use. Defaults to 5. Version 6 is under development and limited.
The SSH application implements the SSH (Secure Shell) protocol and - provides an SFTP (Secret File Transfer Protocol) client and server. +
The Erlang Secure Shell (SSH) application,
The examples in the following sections use the utility function
-
The following examples use the utility function
+
If nothing else is stated, it is presumed that the
The user otptest, that has bash as default shell, uses the - ssh:shell/1 client to connect to the openssh daemon running on a - host called tarlop. Note that currently this client is very simple - and you should not be expected to be as fancy as the openssh - client.
+The user
1> ssh:start().
@@ -62,24 +67,27 @@
logout
3>
+ Notice that this is a simple client that is not expected to be as + fancy as the openssh client.
The option system_dir must be a directory containing a host - key file and it defaults to /etc/ssh. For details see section +
The
Normally the /etc/ssh directory is only readable by root.
+Normally, the
The option user_dir defaults to the users ~/.ssh directory
+The option
In the following example we generate new keys and host keys as - to be able to run the example without having root privileges
+Step 1. To run the example without root privileges, + generate new keys and host keys:
$bash> ssh-keygen -t rsa -f /tmp/ssh_daemon/ssh_host_rsa_key
@@ -88,8 +96,10 @@
[...]
- Create the file /tmp/otptest_user/.ssh/authorized_keys and add the content - of /tmp/otptest_user/.ssh/id_rsa.pub Now we can do
+Step 2. Create the file
Step 3. Start the Erlang
1> ssh:start().
@@ -100,7 +110,8 @@
3>
- Use the openssh client from a shell to connect to the Erlang ssh daemon.
+Step 4. Use the openssh client from a shell to connect
+ to the Erlang
$bash> ssh tarlop -p 8989 -i /tmp/otptest_user/.ssh/id_rsa\
@@ -113,9 +124,12 @@
1>
- There are two ways of shutting down an SSH daemon
+There are two ways of shutting down an
1: Stops the listener, but leaves existing connections started by the listener up and running.
+Step 5a. Shut down the Erlang
3> ssh:stop_listener(Sshd).
@@ -123,7 +137,8 @@
4>
- 2: Stops the listener and all connections started by the listener.
+Step 5b. Shut down the Erlang
3> ssh:stop_daemon(Sshd)
@@ -134,16 +149,17 @@
In the following example, the Erlang shell is the client process + that receives the channel replies.
-In the following example the Erlang shell is the client process - that receives the channel replies.
+The number of received messages in this example depends on which OS
+ and which shell that is used on the machine running the
If you run this example
- in your environment you may get fewer or more messages back as
- this depends on the OS and shell on the machine running the ssh
- daemon. See also
Do a one-time execution of a remote command over
1> ssh:start().
@@ -162,7 +178,8 @@
6>
- Note only the channel is closed the connection is still up and can handle other channels
+Notice that only the channel is closed. The connection is still up and can + handle other channels:
6> {ok, NewChannelId} = ssh_connection:session_channel(ConnectionRef, infinity).
@@ -172,7 +189,9 @@
Start the Erlang
1> ssh:start().
@@ -184,7 +203,7 @@
3>
- Run the openssh sftp client
+Run the OpenSSH SFTP client:
$bash> sftp -oPort=8989 -o IdentityFile=/tmp/otptest_user/.ssh/id_rsa\
@@ -197,7 +216,9 @@
Fetch a file with the Erlang SFTP client:
1> ssh:start().
@@ -210,10 +231,10 @@
A very small SSH subsystem that echos N bytes could be implemented like this.
- See also
A small
-module(ssh_echo_server).
@@ -267,7 +288,9 @@ terminate(_Reason, _State) ->
ok.
- And run like this on the host tarlop with the keys generated in section 3.3
+The subsystem can be run on the host tarlop with the generated keys,
+ as described in Section
1> ssh:start().
@@ -293,6 +316,7 @@ terminate(_Reason, _State) ->
{ssh_msg, <0.57.0>, {closed, 0}}
7> {error, closed} = ssh_connection:send(ConnectionRef, ChannelId, "10", infinity).
+See also