Communication between different hosts through shell scripts.

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Communication between different hosts through shell scripts.
# 1  
Old 06-20-2011
Communication between different hosts through shell scripts.

1) I have two scripts named as, running two different hosts host1 and host2
2) So now how to execute on host2 from on host1
3) Also I have few queries regarding the same as I want to execute few commands with sudo and with different user in script so how this can be achieved without user intervention ( I mean script should not ask for a password when we run this.)
Please provide any pointers to achieve this. Really it would be of immense help for me
# 2  
Old 06-20-2011
IMHO, best way, is to use SSH with keys. Pretty much all *ix has ssh nowadays. However if you have some really, really, really old hosts or some kind of *ix based appliance without ssh, you might be able to fall back to using rsh (not restricted shell but the remote shell, it's called remsh if done from HP-UX) and using .rhosts controls (which are insecure, so you may have to put an option on service start to fix that) to avoid having to use a password.

For ssh with keys, generate your local key (the platform making the calls) and append the public key portion into the remote user's ~/.ssh/authorized_keys (or sometimes it's authorized_keys2) file. Then you should be able to ssh (get a shell) from the local host to the remote host at the remote user without a password... you can run scripts and communicate back and forth through that as well.

---------- Post updated at 03:04 PM ---------- Previous update was at 03:04 PM ----------

For the sudo side, look at the NOPASSWD option for commands that can be run.
# 3  
Old 10-19-2011
Thanks for your recommendations.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to copy a tar file on a series of remote hosts and untar it on those hosts?

Am trying to copy a tar file onto a series of remote hosts and untar it at the destination. Need to do this without having to do multiple ssh. Actions to perform within a single ssh session via shell script - copy a file - untar at destination (remote host) OS : Linux RHEL6 (3 Replies)
Discussion started by: sankasu
3 Replies

2. Shell Programming and Scripting

SSH to remote hosts in shell scripting

Hi There, I have a file contaning some 100 servers names one by one the file called redhat_servers.txt I want to prepare a script where it should give me the host name and kernal version. I wrote like this, #!/bin/bash while read line do ssh $line "uname -nr" done <... (3 Replies)
Discussion started by: kumar85shiv
3 Replies

3. Shell Programming and Scripting

Ssh to 100s of hosts with password in a shell script or text file

I have about 500 hosts where I need to ssh by sending the password on the command line or in a text file in a clear text . However I am not able to download "sshpass" or other tools . Any other ways to pass the password in a script ? (3 Replies)
Discussion started by: gubbu
3 Replies

4. Linux

Shell ${1:-/etc/hosts} meaning

Hello. In some script, I saw: filename=${1:-/etc/hosts} if && ; then md5sum $filename else echo “$filename can not be processed” fi # Show the file if possible ls -ld $filename 2>/dev/null What does the first line means? In $filename I still got /etc/hosts. (2 Replies)
Discussion started by: lozicd3
2 Replies

5. AIX

aix tcp wrappers hosts.allow hosts.deny?

hi all just installed the netsec.options.tcpwrapper from expansion pack, which used to be a rpm, for my aix 6.1 test box. it is so unpredictable. i set up the hosts.deny as suggested for all and allow the sshd for specific ip addresses/hostnames. the tcpdchk says the hosts allowed and... (0 Replies)
Discussion started by: wf201626
0 Replies

6. Shell Programming and Scripting

communication between shell and and a demon 'c' program

Hello, i have a demon 'c' program that have a dynamic table of logic registers ( 2000 variables ). exemple of registers: I1.34.5 M23.4.1 I want from shell acess to this table of registers. How can i do this? with something like for read I1.34.5: #cat... (3 Replies)
Discussion started by: rzyz
3 Replies

7. Shell Programming and Scripting

communication framework/sfw for stand alone ksh scripts.

Hi all: This is an open question. Which way/framework/sfw do you use to communicate/signals scripts running stand alone (on the same and different machines). For example sometimes I use witness files to "trigger" that other script star/stop work and another one do a task of a job. Of course;... (0 Replies)
Discussion started by: rbadillarx
0 Replies

8. OS X (Apple)

Inter-shell communication

If I open two bash shells and telnet from Shell 2 to a remote server (on the Net), is there a way to direct input from Shell 1 to the telnet shell? The telnet shell is a limited environment with a specific command set. I want to direct commands from Shell 1 and, if possible, put 1-second... (2 Replies)
Discussion started by: xinUoG
2 Replies

9. Shell Programming and Scripting

Help with shell script which logins to hosts

By a shell script When I am logging into hosts one by one with ssh. I am getting below message. Pseudo-terminal will not be allocated because stdin is not a terminal. stty: : Invalid argument stty: : Invalid argument Can you please suggest what should I do to stop this? ... (10 Replies)
Discussion started by: KuldeepSinghTCS
10 Replies

10. OS X (Apple)

Serial Communication from shell Mac OS X PHP script

Hi again, I spoke with Keyspan and they assured me the USB to Serial device was working if I could use the Screen tool. I asked why I was unable to redirect stdin/stdout to and from the /dev/tty. device and was told there was no reason I shouldn't be able to do so. I have tried: ... (1 Reply)
Discussion started by: cpfogarty
1 Replies
Login or Register to Ask a Question