Currently I'm using the standard netcat -e /bin/sh to provide a remote shell for other computers to access.

The problem is however that this shell is rather terrible, since it has limited output. For example if I send some invalid command xxxxx, I will get no response from the machine, but on the machine there will be an error in the terminal saying /bin/sh: xxxxx: not found.

If I use the shell to launch a console application, often I cannot see anything the console application outputs, and I can't Ctrlz over the shell because that will close netcat on the machine. It's a mess, I'd like it to work just like SSH (which I can't use).

Instead of piping everything to /bin/sh like I'm doing with netcat, would it be possible to create a custom application instead that will show me all the outputs in a terminal? Is it possible somehow get the text off the terminal, regardless of what process wrote to it?

Would it be possible to start an sshd on the box, and then netcat -e "ssh root@localhost" and do it that way? (I've tried this, doesn't seem to work).

I'm looking for any kind of solution.

  • 3
    Why can't you use SSH? Or rsh or telnet for that matter? Trying to reproduce their functionality is going to be a lot of work.
    – Mat
    Mar 29 '14 at 8:33
  • If you have an answer for your own question, please put it as an answer rather than an edit to the question. That will help future visitors with the same issue. Thank you.
    – mattdm
    Mar 29 '14 at 12:37

Creating a "custom application" would be re-implementing telnet / ssh. This is, of course, possible, but not necessary.

If there is sshd (or telnetd) on the host you can start it from your netcat-shell session with e.g. /usr/sbin/sshd -p <port> -D 2>&1 and then do ssh -p <port> root@<host> on your client. You might need to add further options to sshd, perhaps create a config file and give it in the command line: /usr/sbin/sshd -f <config-file> ...

If not, you can use the netcat session to upload telnetd or sshd, set up the needed environment / config and run it on some port.

You can also make a wrapper around your shell to redirect stderr to stdout, like /bin/sh 2>&1, which would allow you to see stderr in your netcat session, but would not give you "real terminal" functionality.

Another option is DISPLAY=<client>:0 xtrem if you have xterm or equivalent on the host and X Server on the client.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.