2

I need to establish a persistent disconnection-proof terminal session similar to what the dtach, abduco or tmux tools provide, but with a big constraint: I cannot install any software and the only tools I have available are OpenSSH and BusyBox.

I need a full persistent terminal session that I can connect, disconnect and reconnect to. Its state must be saved and any running command must continue running on disconnection.

Do OpenSSH or BusyBox provide any session management facility? Can it be implemented with some shell magic using only OpenSSH and BusyBox?

if9y4d
  • 21
  • 2
  • 2
    Can you specify what you need more precisely? Do you just need to be able to launch a command and have it continue after you log out, or do you really need full session control where you can log on again and continue your shell session exactly as it was? Do you _need_ to run things on the remote box or do you simply need to be able to process data found on the remote but could work on them locally (so, maybe mount a remote directory on your machine with `sshfs`)? We might be able to find workarounds, but we'd need to know exactly what your needs are. – terdon Feb 15 '20 at 18:39
  • _I cannot install any software_: can you save a file to your home directory and run it? – Eduardo Trápani Feb 15 '20 at 23:43
  • @EduardoTrápani I can but I shouldn't. I'm only allowed to login and run commands or scripts. – if9y4d Feb 16 '20 at 00:22
  • If you have netcat compiled into your BusyBox, you can run a disconnect-proof shell and then feed it commands and get output over a socket. https://unix.stackexchange.com/questions/336876/simple-shell-script-to-send-socket-message I suspect that if you have a security department that won't let you run tmux or screen, they won't let you run a shell that needs no password to access, but maybe with a suitable firewall it would be acceptable. – Mark Plotnick Feb 17 '20 at 14:47

1 Answers1

0

Can BusyBox do something similar to tmux/dtach?

Short answer: no, it cannot. And neither can OpenSSH.

Longer answer: since you are going to be writing scripts and leave them running them on the host, you might as well, before you do that, run screen (more info). It will let you do what you want.

To run it, you should upload the program, just as you upload your scripts. But you probably will not have the libraries screen needs, so you will have to upload a static version (a program that has all the libraries in the binary).

We don't have information on the busybox host, but you can cross-build screen statically for its processor/system. Or, if it is an ARM host, you can use a prebuilt static version, like this one. But it's best to build it yourself, from source.

Eduardo Trápani
  • 12,032
  • 1
  • 18
  • 35