Solved

Connecting to a SSH Server

Posted on 2004-08-30
6
1,056 Views
Last Modified: 2010-07-27
Hello Experts.
I have a Linux RedHat9 box running SSH Server on port 22.
Now, i want write a small apllication in Delphi 7 that allow me to connect to this SSH Server.

What i want to do:
 1- Connect from my Windows XP to my Linux on port 22.
 2- Make login
 3- Execute a shell script (myscript.sh)
 4-Exit

I don't want use programs like putty because it's not necessary!
Everything that i want to do, is open my Delphi Application, enter my username and password, and click a simple button.
So, my Delphi Application will connect to the remote host, run my script and Exit.

Thank's in Advanced.
0
Comment
Question by:Spetson
6 Comments
 
LVL 2

Accepted Solution

by:
DarkCore_ earned 400 total points
Comment Utility
In Delphi? Why don't do this as a cron task or a php/cgi in apache?

In Delphi you'll need a ssh-connection component ( I don't know about any free component ), parse text ... etc ... it will be so complicated.

If you have kylix you can do too a small server listening at any port which listens for a connection and recieves a packet ( a string ), then run the script, for example.

Edu
0
 

Author Comment

by:Spetson
Comment Utility
huummm!
Ok, i will explain All my situation:
I will host a game server in my linux box...
Some members of my clan (game clan) don't know absolute nothing about ssh connection, telnet, etc...
So, i need something very simple for this guys...
a php or perl script sounds good, as my linux have Apache running at port 80, but i have already tested this option, without success...
The php script freeze's when start the script myscript.sh using exec() command or `myscript.sh`.

What the myscript.sh does:
1-Check if the game server is not running (avoid multiple instances), if it's running, kill it.
2-restart the application.

So, if you have some good idea, please let me know.

I Know that this topic area is about Delphi, but ANY SOLUTION for the Question will be very apreciate.

And...
About Kylix, i don't have this great program for linux :(
About cron task, the start/stop action, Must be interactive (user command) and not autamatic.

Thank's.
0
 
LVL 4

Expert Comment

by:Colin_Dawson
Comment Utility
You might want to check out the indy components.  That will give you the connection over port 22.  The SSH bit I can't help you with though.

0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 2

Expert Comment

by:DarkCore_
Comment Utility
in your script, try to run it with

   run_program &

to let it go to background.

In Apache the problem could be permissions. Be sure your apache ( with user Nobody ) have permissions to run your program. What kind of error does?

You can try too a simple sequence ... let the user install putty. Give them a 'standard' username and a password. In their .bashrc profile include some lines like

   ./myscript.sh &
   logout

Edu
0
 
LVL 12

Expert Comment

by:Ivanov_G
Comment Utility
you can use TIdRSH (from Indy). This is Unix Remote Shell component and you can execute the shell script...
0
 

Author Comment

by:Spetson
Comment Utility
Ok guys!
It’s funny, but the found solution was not in Delphi, but using a php script that will do the entire job for me.
Thank you to DarkCore for all the support by email.
I decided to not post the solution here, as this Topic Area is about Delphi and not Php.
But anyways, if someone is interested in this question, please post your comments here and let us know.

Thank’s
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now