I need to run any "remote shell daemon" (ssh, telnet, netcat, socat... I don't mind) as non-root user. The remote shell should provide tab-completion and I want to be able to browse history using arrows.

I am currently using a netcat-based solution, but I loose tab-completion and I am unable to browse history using arrows

On server side :

# Run the "remote shell daemon"
$ mkfifo fifo
$ nc -l 2000 <fifo | /bin/bash &> fifo
$ rm fifo

On client side :

# Connect to the remote shell
$ nc $REMOTE_ADDR 2000

Adding the -i or -l argument to bash does not help.

  • If you use ssh and your remote shell is properly configured then you should have tab-completion and history browsing. At least I have when I login to my server using Ubuntu 12.04 on both machines. – Anthon Apr 18 '13 at 12:42
  • I need to run a "remote shell" daemon as non-root user. Sshd typically runs as root. – Xion345 Apr 18 '13 at 12:43
  • As long as the config files and the keys are owned by the user running sshd, and you use a port number > 1024 you don't need to run sshd as root. – Anthon Apr 18 '13 at 13:05
  • Why do you need to run the daemon as a regular user? What are you trying to achieve? – terdon Apr 18 '13 at 13:32
  • 1
    @terdon : I use a computing grid and I don't have a shell access to all nodes of the grid. The only thing I can do is submit scripts to the system (it's Grid Engine), and they will be scheduled on the node I specified. I would like to write a script that would allow me to have a shell access to a node of the grid. – Xion345 Apr 18 '13 at 13:47

socat(1) could be of some help.

From http://stuff.mit.edu/afs/sipb/machine/penguin-lust/src/socat-

// poor mans 'telnetd' replacement
# socat tcp-l:2023,reuseaddr,fork exec:/bin/login,pty,setsid,setpgid,stderr,ctty
// and here an appropriate client:
$ socat -,raw,echo=0 tcp:

Here, the example uses "login" which obviously requires a root access but I succesfully tested with /bin/zsh. This implies that security is not a problem... Otherwise, as they say in the webpage where I found out this tip, you could use a client authentication with SSL to make sure only you can actually log in.


Tab completion with netcat:

- stty   : change and print terminal line settings  
- echo   : echo input characters  
- icanon : enable erase, kill, werase, and rprnt special characters
- sane   : Revert back default terminal line setting

Command :

bash-4.3# stty -echo -icanon && nc ... && stty sane

Example :

stty -echo -icanon && nc 0 5000 && stty sane Note : 5000 is the port number

For more Info you can refer to linux man page :

Linux man Page - stty

Linux man Page - netcat

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.