Thursday, April 14, 2011

SSH client application using Delphi


I need my Delphi application to issue very simple commands for example
ssh -l userid "df -h"'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.


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:
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:
A little more complicated solution is to use Synapse Lib to connect to the server by using SSL, like this example:
I posted an article in my blog, with a simple class to let you do what you want:
Hope this helps.

+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