Solved

Calling remote script in unix

Posted on 2015-01-14
5
236 Views
Last Modified: 2015-01-27
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!
0
Comment
Question by:celtician
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40550589
Somehow you have to login everytime.  Linux, Unix, Windows, and OSX all require you to be logged in to access any files.
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 200 total points
ID: 40550614
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
 
LVL 9

Accepted Solution

by:
Carlos Ijalba earned 300 total points
ID: 40550881
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
 
LVL 29

Expert Comment

by:serialband
ID: 40554285
That's the first time I've heard it called an "ssh trust relationship" before.  That's just standard ssh keys without passphrases.
0
 
LVL 9

Expert Comment

by:Carlos Ijalba
ID: 40560768
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

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

739 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