原创文章,转载请注明出处:服务器非业余研究http://blog.csdn.net/erlib 作者Sunface
联系邮箱: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:
为了让它工作起来,你通常需要把你的SSH在远程服务器上部署好。但因为我们只是做实验,就可以像下面这样子做:
-----------------------------------------------------------------------------------$ 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.
[注4]:这种命令对所有连接远程Erlang节点的方法都不要用!