[erlang-questions] ssh client

128 views
Skip to first unread message

Daniel Goertzen

unread,
Sep 1, 2010, 12:17:45 PM9/1/10
to Erlang Questions
I want to write a program that will chat with another remote program via
SSH. Erlang SSH is a bit complex, and I was unable to find an example of
what I wanted, so I thought I would confirm my approach here before barking
up the wrong tree. Here is what I was going to do:


1. Open a connection with ssh:connect()
2. Open a channel with ssh_connection:session_channel()
3. Call ssh_channel:start_link() to create my handler process.
4. In my callback module, init() will call ssh_connection:exec() to invoke
the remote program.
5. Incoming data gets sent to my handle_ssh_message() callback. I send data
with ssh_connection:send()

Do I have it right?

It would be nice if there was a "port" abstraction for an ssh channel, so I
could treat locally and remotely invoked programs identically... I guess it
wouldn't be hard to write my own wrapper for that.

Thanks,
Dan.

Kenji Rikitake

unread,
Sep 7, 2010, 12:57:56 AM9/7/10
to Daniel Goertzen, Erlang Questions
http://github.com/jj1bdx/sshrpc/

Far from a complete one - but might be useful.
Kenji Rikitake

In the message <AANLkTi=xDOQ7P8nfCW-=P+98daXyKW=RJhO4N...@mail.gmail.com>
dated Wed, Sep 01, 2010 at 11:17:21AM -0500,

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-questio...@erlang.org

Daniel Goertzen

unread,
Sep 7, 2010, 3:17:04 PM9/7/10
to Kenji Rikitake, Erlang Questions
Thanks Kenji. I did come across that and it was helpful. In the end,
ssh_sftp and ssh_sftpd were the readily available examples I was looking
for.


This might be of interest to the list, so I'll share it...

I stress tested Erlang and SSH by establishing 1000 concurrent SSH client
sessions. Each server sent back an 8 byte message every 250ms. On my
Windows Core2Duo 3GHz, system load was ~25%.

To compare, I also wrote the client in Python using Paramiko for SSH (1 OS
thread per connection). CPU load and memory usage was consistent with the
Erlang solution, but it died at 400 connections due to address space
exhaustion (thread stacks were too big...probably fixable, but I didn't try
too hard)

Also, I wrote a Python client that used plink.exe for SSH. (1 OS process per
connection). CPU load was consistent with the Erlang solution, but memory
use was insane. It died at ~500 connections due to lack of file descriptors
(also probably fixable, but I didn't try).

In all cases, the server was a single linux machine running Erlang/SSH. The
actual use case for all this is to talk SSH to 1000 individual embedded
systems on a large LAN. I am pleased with the way Erlang has behaved.

Dan.

--
Daniel Goertzen
-----------------
da...@networkintegritysystems.com (work)
daniel....@gmail.com (home)
-----------------
1 204 272 6149 (home/office)
1 204 470 8360 (mobile)
-----------------

Reply all
Reply to author
Forward
0 new messages