Thursday, April 14, 2011

SSH client application using Delphi

Source: www.stackoverflow.com

I need my Delphi application to issue very simple commands for example
ssh -l userid host.domain.com "df -h"

userid@host.domain.com'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.


Suggestions:

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.


Responses:
+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 Jan 29 '10 at 16:51

Thank you very much, this is exactly what I needed. – PA Jan 29 '10 at 20:24
+1 for your blog post, I've been looking for that for a long time!! Thank you! – migajek Jan 29 '10 at 21:52

+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 Aug 30 '10 at 17:51

0 Comments: