[Erlang crisis] (4.3) SSH daemon, erlangssh

Source: Internet
Author: User

[Erlang crisis] (4.3) SSH daemon, erlangssh
Original article, reprinted please indicate the source: Server non-amateur research http://blog.csdn.net/erlib author SunfaceE-mail: cto@188.com
SSH Daemon

Erlang/OTP comes shipped with an SSH implementation that can both act as a server and a client. Part of it is a demo application providing a remote shell working in Erlang.
To get this to work, you usually need to have your keys to have access to SSH stuff remotely in place already, but for quick test purposes, you can get things working by doing:

Assumerlang/OTP comes with an SSH implementation that can be used as a server or a client. Partial Implementation of SSH is the demo of remote shell in erlang.
To make it work, you usually need to deploy your SSH on the remote server. But because we only do experiments, we can do this as follows:

Bytes -----------------------------------------------------------------------------------
$ mkdir /tmp/ssh
$ ssh-keygen -t rsa -f /tmp/ssh/ssh_host_rsa_key
$ ssh-keygen -t rsa1 -f /tmp/ssh/ssh_host_key
$ ssh-keygen -t dsa -f /tmp/ssh/ssh_host_dsa_key
$ erl
1> application:ensure_all_started(ssh).
{ok,[crypto,asn1,public_key,ssh]}
2> ssh:daemon(8989, [{system_dir, "/tmp/ssh"},
2> {user_dir, "/home/ferd/.ssh"}]).
{ok,<0.52.0>}
Bytes -----------------------------------------------------------------------------------

I 've only set a few options here, namely system_dir, which is where the host files are, and user_dir, which contains SSH configuration files. there are plenty of other options available to allow for specific passwords, customize handling of public keys, and so on 3.

Worker first sets several options, specifying the system directory (system_dir) for storing the host file, and specifying the user directory (user_dir) containing the SSH configuration file ). in fact, there are a lot of other options: set a specific password, custom public Key (public keys) and so on 3.

To connect to the daemon, any SSH client will do:

Any SSH client of supervisor can connect to the daemon by using the following code ):

Bytes -----------------------------------------------------------------------------------
$ ssh -p 8989 ferd@127.0.0.1
Eshell Vx.x.x (abort with ^G)
1>
Bytes -----------------------------------------------------------------------------------
And with this you can interact with an Erlang installation without having it installed on the current machine. just disconnecting from the SSH session (closing the terminal) will be enough to leave. do not run functions such as q () or init: stop (), which will terminate the remote host. 4

Then you can use the Erlang of other nodes without installing Erlang locally. After you disconnect the SSH session directly (close the terminal), you can safely exit. However, you must never output command 4 to terminate a remote shell, such as q () or init: stop. (Remember that you cannot call q () or init: stop ()-Sunface to connect to a remote node)

If you have trouble connecting, you can add the-oLogLevel = DEBUG option to ssh to get debug output.

If the supervisor fails to connect to SSH, you can add the option-oLogLevel = DEBUG for SSH and then output the debug information.

[3] Complete instructions with all options to get this set up are available athttp: // www.erlang.org/doc/man/ssh.html?daemon-3.
[4] This is true for all methods of interacting with a remote Erlang node.

[NOTE 3]: For a description of all options, see: http://www.erlang.org/doc/man/ssh.html#daemon-3.
[NOTE 4]: This command is not used for all methods to connect to remote Erlang nodes!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.