Calling remote script in unix

I need to get the result of a function in some remote unix machine,

i an on machine1

i need to get script.ksh result from machine two

what i use to do is ssh user@machine2
then i enter password
and then from machine2 i access the folder where the script is located and i execute it getting the result (is always a text string)

instead of having to log to the machine2 everytime i need the result, i would like to make the call directly from machine1, how can that be possible??

thanks!
LVL 1
celticianAsked:
Who is Participating?
 
Carlos IjalbaSenior SysadminCommented:
Celtician,

What you have to do is setup an "SSH trust relationship" between both machines, that way you will be able to execute scripts remotely without login.

You then create another local script to just invoke the remote script:

script_2.ksh
ssh user@machine2 script.ksh

And that way you can execute script.ksh to obtain results locally and script_2.ksh to access the other box.

To setup the ssh trust:

1.

Generate a public and private key pair on machine1

2.

Copy the public keys (id_rsa.pub) to machine2 (remote host).

3.

On machine2, copy your public key to the authorized_keys file (cat  id_rsa.pub >> .ssh/authorized_keys)

4.

Try to connect t from machine1 to machine2, ( [machine1]# ssh machine2 ) if it works without asking for password, you're set.
0
 
Dave BaldwinFixer of ProblemsCommented:
Somehow you have to login everytime.  Linux, Unix, Windows, and OSX all require you to be logged in to access any files.
0
 
ozoCommented:
From machine1, you can execute
result=`ssh user@machine2 script.ksh`

You still have to enter the password, or set up an authentication key
0
 
serialbandCommented:
That's the first time I've heard it called an "ssh trust relationship" before.  That's just standard ssh keys without passphrases.
0
 
Carlos IjalbaSenior SysadminCommented:
When you create a trust between 2 hosts using ssh keys, the jargon is "ssh trust relationship", "ssh trust between 2 servers", "relación de confianza", etc...

Just do a search for those terms in google...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.