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:
-----------------------------------------------------------------------------------$ 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>}
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------$ ssh -p 8989 ferd@127.0.0.1
Eshell Vx.x.x (abort with ^G)
1>
-----------------------------------------------------------------------------------
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
If you have trouble connecting, you can add the -oLogLevel=DEBUG option to ssh to get debug output.
?如果无法连接SSH成功,可以为SSH加一个选项 -oLogLevel=DEBUG, 然后输出debug信息。[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.
原文地址:http://blog.csdn.net/erlib/article/details/40947719