Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

socat - exec:'bash -li',pty,stderr,ctty -> bash: no job control in this shell

What options should I use to get fully fledged shell as I get with ssh/sshd?

I want to be able to connect the shell to everything socat can handle (SOCKS 5, UDP, OpenSSL), but also to have a nice shell which correctly interprets all keys, various Ctrl+C/Ctrl+Z, tab completion, up/down keys (with remote history).

  • Update 1: Found "setsid" socat option. It fixes "no job control". Now trying to fix Ctrl+D.

  • Update 2:

    socat file:`tty`,raw,echo=0 exec:'bash -li',pty,stderr,setsid,sigint,sane
    . Not it handles Ctrl+D/Ctrl+Z/Ctrl+C well, I can start Vim inside it, remote history is OK.

share|improve this question
    
Looks like all requirements are met now. Now to mark the question as closed? – Vi. Mar 24 '10 at 23:43
1  
Post your findings as an answer and in 48 hours you can accept it. – Dennis Williamson Mar 24 '10 at 23:53
up vote 3 down vote accepted

The problems were:

  1. Missing "setsid" option in right side of socat. It will cause bash not to be controller of session.
  2. Using "-" in the left side of socat. The proper thing is `tty`,raw,echo=0.

Now I can have a shell over all things socat can support and can start vim/screen/ssh, interrupt ping with ^C, end cat with ^D and do everything else in that shell.

If bash breaks lines wrong and/or vim is too small or too big, you can use termsize to fix it easily.

share|improve this answer
    
Using STDIN:raw,echo=0 instead of file:`tty`,raw,echo=0 worked better for me. I was able to use this (using two socats with a unix domain socket in the middle) to get shell access to a container in a different network namespace. – Seth Robertson Apr 15 '15 at 23:19
    
@SethRobertson For playing with Linux namespaces, also see my other project: github.com/vi/dive – Vi. Apr 16 '15 at 2:24
    
@SethRobertson, I use this way of starting something in other existing network namespace: dived -J -S -T --setns /proc/12345/ns/net -- /bin/bash. This way only network namespace gets set, everything else (other namespaces, controlling terminal, parent process) is preserved. – Vi. Apr 16 '15 at 4:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .