Operating System - HP-UX
1820594 Members
1420 Online
109626 Solutions
New Discussion юеВ

Re: Executing command on Remote System

 
SOLVED
Go to solution
Sanjay Verma
Super Advisor

Executing command on Remote System

Hi Frineds,
I want to execute command on several remote systems. Without modifying the hosts etc. files, how I can accomplish this? The concern is, the password can not be supplied with the rlogin or rexec command.
Co-operation - The biggest chain reaction
19 REPLIES 19
twang
Honored Contributor
Solution

Re: Executing command on Remote System

Create hosts.equiv or .rhosts on the user's home dir on your remote server, syntax should be :

hostname username

(the hostname is the box on which you issue command, /etc/hosts.equiv isn't used for root).
Sanjay Verma
Super Advisor

Re: Executing command on Remote System

Hi Twang,
As indicated I can not modify any files and needs to execute the command without any modification to the files on the target server. Any other alternatives?
Co-operation - The biggest chain reaction
Fragon
Trusted Contributor

Re: Executing command on Remote System

That's easy,for example,
root in hosta want to execute command on hostb, you can edit the .rhosts in hostb:
hosta root
Now things are done!!!

-ux
Sanjay Verma
Super Advisor

Re: Executing command on Remote System

Hi hp-ux, I want to execute the command as a normal user + don't want to modify any files even .rhots.
Co-operation - The biggest chain reaction
Sanjay Verma
Super Advisor

Re: Executing command on Remote System

Hi hp-ux, I want to execute the command as a normal user + don't want to modify any files even .rhosts.
Co-operation - The biggest chain reaction
Fragon
Trusted Contributor

Re: Executing command on Remote System

I think it is impossible if the "~/.rhosts or /etc/hosts.equiv" is not set correctly!
Or you must offer the password when use r* command!
Of course, a hacker can ......

:p
-ux
twang
Honored Contributor

Re: Executing command on Remote System

I think you need to either set up a .rhosts in the users home dir or set up /etc/hosts.equiv.

See the man pages for the following:
# man 4 hosts.equiv
# man rcp
Rajeev  Shukla
Honored Contributor

Re: Executing command on Remote System

Trust me there there is no other way to run a remote command on other systems.
But if you like playing with C and libraries of C you can by using rcmd() function but this should be run as root.
But hide this program if you write its very dangerous...


Rajeev
Sanjay Verma
Super Advisor

Re: Executing command on Remote System

Hi hp-ux / friends, let me explain you this. The user "sanjay" can access the server "hpux" from server "sun" properly. Now, "sanjay" wants to execute certain commands from within a script on the "hpux" server from "sun" sevrer. How he can do this?
Co-operation - The biggest chain reaction
Fragon
Trusted Contributor

Re: Executing command on Remote System

[Hi hp-ux / friends, let me explain you this. The user "sanjay" can access the server "hpux" from server "sun" properly. Now, "sanjay" wants to execute certain commands from within a script on the "hpux" server from "sun" sevrer. How he can do this?]
Hi,
1.What do you mean "properly"? Can you rlogin from SUN to HP-UX without a password?
2.If so, you can do nothing ,just use
#rexec HOST_OF_HP-UX command-in-hp-ux

Have a good day!
-ux
Con O'Kelly
Honored Contributor

Re: Executing command on Remote System

Hi Sanjay

I presume you are looking to use the rcp or remsh commands??
When you say access, I presume you mean you can telnet or ssh to from hpux to sun server??

Remotely executing commands (remsh) relies on having either a .rhosts or /etc/hosts.equiv file.
As far as I am aware there is no way around this.

If you explain what you are trying to achieve i.e. what commands you are trying to run or what files you want to copy, then someone may be able to offer a solution.

Cheers
Con


Sanjay Verma
Super Advisor

Re: Executing command on Remote System

Hi Con/hp-ux/Shukla,
Sorry to confuse with "Sun". This is not Sun Solaris but the host name "sun". Let me further explain this:
User1
Host1
Host2
User1 wants to execute some commands e.g., #find /home/sanjay -size 10c -exec rm {} \; on host2 using a script created on host1.
Con is right is some extent but I want to achieve this without modifying and .rhosts file etc.
Hope this gives you a much clear picture.
Co-operation - The biggest chain reaction
Con O'Kelly
Honored Contributor

Re: Executing command on Remote System

Hi (again).

Sorry if I'm missing your point.

If you want to execute that find command from host1 on host2 then you need to use the remsh command. This relies on having a .rhosts or /etc/hosts.equiv.

Cheers
Con
Jean-Louis Phelix
Honored Contributor

Re: Executing command on Remote System

Hi,

Script on host1 must be available first on host2. Then, if you don't want to have a .rhosts file, use a rexec command, but you will be prompted for the password on host2 before each execution.

Regards.
It works for me (┬й Bill McNAMARA ...)
yogesh_4
Regular Advisor

Re: Executing command on Remote System

there is no way w/o modifing ~/.rhosts or /etc/hosts.equiv files or if you use "rexec" then you have to give the password.
Bill Douglass
Esteemed Contributor

Re: Executing command on Remote System

You should be able to script this with expect

http://hpux.cs.utah.edu/hppd/hpux/Tcl/expect-5.38/

(depends on tcltk being installed as well).

You can have expect send the password to rexec when prompted.

Be aware that all of these approaches have security issues; mainly, your password is embedded in a script and sent in clear-text over the network.
Massimo Bianchi
Honored Contributor

Re: Executing command on Remote System

Hi,
you can think of using ssh or openssh.

It let's you configure equivalence of users, without modifying existing file.

You will have to install ssh on each hosts, and configure it, but your .rhosts will not be modified.

Otherwise expected seems the best choiche, as pointed out.

HTH,
Massimo
Chris Vail
Honored Contributor

Re: Executing command on Remote System

As Massimo points out, your best bet is to install and use secure shell. You can get this precompiled for HP at http://software.hp.com. Its also available for other Unix platforms, and even M$ platforms for free or very cheap. It won't be hard to find: Google is your friend.
Since it appears that all you want to do is script; install secure shell on both (or all systems, then configure it according to the document I've attached. This will allow you to securely access remote systems, run commands and display/capture data back to the intiating system.
The only caveat is that the initial connection between systems is slow (in HPux versions prior to 11i). After the initial connection/handshake is made, it is just as fast as remsh, rlogin, rcp, or any of the others.
Just be careful to check permissions and ownerships, as outlined in the document. It'll work GREAT!


Chris
Caesar_3
Esteemed Contributor

Re: Executing command on Remote System

Hello!

If you will use the ssh you can execute
the ssh command (not remsh) and if you
not alowed user connect automaticly it will
ask for password and if it's good execute the command.

So start using ssh.

Caesar