# rshd + inetd = lightest way to execute commands remotely?

## grant123

Is rshd+inetd the lightest choice for executing commands on a different system?  I'm trying to save every CPU cycle I can with this project.  I'm not concerned about security because the system running rshd+inetd will be connected via ethernet directly to a trusted system.Last edited by grant123 on Thu Dec 06, 2012 11:28 am; edited 2 times in total

----------

## truc

```
nc6 -l -p 9999 -e /bin/sh
```

(on the server side)

This is probably lighter and less secure!  :Laughing: 

(nc6 or nc is from the netcat6 package)

----------

## grant123

Wow, I wish I would have asked before I spent all day on rshd+inetd.  :Smile: 

I'm playing with nc6 and it's incredibly easy to get working, but I can't find a way to use it like rsh where the client can just issue a single command.  The client stays open after the commend has been issued.  Is there a way to get the client to issue a single command to the server and then terminate like rsh?

----------

## truc

Actually, I was almost sure this wasn't what you were looking for! Since, I was wrong, and since you're trying to save every CPU cycle you can, you can even do it in udp! Should be even faster and definitely lighter!

As for the the client which does not terminate, did you try the --send-only option:

```
echo ls -l /tmp | nc -u --send-only ::1 9999
```

 :Question: 

----------

## grant123

--send-only makes the client terminate but it would be nice to receive data back from the server before termination.  Is that outside of nc6's abilities?

----------

## grant123

I also noticed that when using UDP, nc6 spawns about 8 or so processes after the first connection from the client.  Have you seen that behavior?

----------

## grant123

Thanks a lot for your help truc!

----------

## truc

 *grant123 wrote:*   

> I also noticed that when using UDP, nc6 spawns about 8 or so processes after the first connection from the client.  Have you seen that behavior?

 

I've just tested, and it doesn't seem to happen here, weird, what are the processes? here is how I monitored the process:

```
watch -n 1 pgrep -fl ^nc
```

What do you have?

----------

