Solved

Connecting to a SSH Server

Posted on 2004-08-30
6
1,066 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
ID: 11931584
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
ID: 11931827
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
ID: 11931868
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 2

Expert Comment

by:DarkCore_
ID: 11931992
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
ID: 11933040
you can use TIdRSH (from Indy). This is Unix Remote Shell component and you can execute the shell script...
0
 

Author Comment

by:Spetson
ID: 11940253
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

815 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

11 Experts available now in Live!

Get 1:1 Help Now