tags:

views:

503

answers:

1

I need my Delphi application to issue very simple commands for example

ssh -l userid host.domain.com "df -h"

[email protected]'s password: XXXXX

Filesystem            Size  Used Avail Use% Mounted on
/dev/sdd5             4.9G  1.7G  3.0G  36% /
/dev/sdc1             1.1G   75M  952M   8% /boot
/dev/sdd2             2.0G   44M  1.8G   3% /var/log

Can you recommend any freeware component or library? I've looked in Tory's pages and googled a bit but cannot find any.

I could also look for alternatives if any.

+7  A: 

You can install Cygwin's OpenSSH Client, then call it from your application and capture it's output.

Here is an example on how to capture the console output: http://delphi.about.com/cs/adptips2001/a/bltip0201_2.htm

Keep in mind, that when you are loggin in to an SSH server, the password is requested, in interactive mode (SSH Client will wait until you type the password), so you must configure automatic login, like it's explained here:

http://magicmonster.com/kb/net/ssh/auto_login.html

A little more complicated solution is to use Synapse Lib to connect to the server by using SSL, like this example:

http://www.amsoftwaredesign.com/downloads/synapse_ssh_test.zip

I posted an article in my blog, with a simple class to let you do what you want: http://leonardorame.blogspot.com/2010/01/synapse-based-ssh-client.html

Hope this helps.

Leonardo M. Ramé
+1 for Synapse, exactly what I would recommend, which is a cleaner solution...although it does require 3rd party DLL's (for the SSL implementation), it doesn't require 3rd party software to be installed.
skamradt
Thank you very much, this is exactly what I needed.
PA
+1 for your blog post, I've been looking for that for a long time!! Thank you!
migajek
+1 - followed your blog post and it works a treat in D2007, exactly the push in the right direction I needed to get going. Thanks!
robsoft