码迷,mamicode.com
首页 > 系统相关 > 详细

[Erlang危机](4.3)SSH守护进程

时间:2014-11-09 11:21:37      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:erlang   ssh   

原创文章,转载请注明出处:服务器非业余研究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:

?Erlang/OTP附带了一个SSH实现,它即可以做服务器,也可以做客户端。SSH的部分实现是erlang中远程shell的演示demo。
?为了让它工作起来,你通常需要把你的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>}
-----------------------------------------------------------------------------------

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.

?在上面我先设置了几个选项,指定了存放host文件的系统目录(system_dir),指定了包含SSH配置文件的用户目录(user_dir).其实还有大量其它选项:设定特定的密码,自定义公钥(public keys)等等3

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

?任意的的SSH客户端都可以通过以下代码连接上这个守护进程(daemon):

-----------------------------------------------------------------------------------
$ 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

?这样你就不用在本地安装Erlang也能使用其它节点的Erlang了。直接断开SSH会话后(关闭终端)就可以安全离开。但千万不能输出q()或init:stop()之类终结远程shell的命令4。(牢记直接要连接远程节点,就不能调用q()或init:stop() - Sunface)

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.

[注3]:关于所有选项的说明见:http://www.erlang.org/doc/man/ssh.html#daemon-3.
[注4]:这种命令对所有连接远程Erlang节点的方法都不要用!

[Erlang危机](4.3)SSH守护进程

标签:erlang   ssh   

原文地址:http://blog.csdn.net/erlib/article/details/40947719

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!