8

When starting the terminal app on my Nexus 4 (OTA 10.1), I connect to my server via ssh <user>@<serverdomain>.

Swiping to another app and swiping back to the terminal kills the connection:

[1]+ Stopped ssh

How can this be kept alive and for how long?

4
  • What android terminal are you using?
    – dufte
    May 10, 2016 at 12:57
  • 3
    There is a fundamental problem with Ubuntu Touch, that background applications get suspended, including the terminal. This causes ssh connections to be dropped. However, [1]+ Stopped ssh means that it is only paused, so you could resume that job using fg. There is a risk that the connection will be broken already, though. May 10, 2016 at 13:26
  • This is the terminal app:uappexplorer.com/app/com.ubuntu.terminal
    – Frunu
    May 16, 2016 at 18:24
  • The fg command is that i needed.
    – Frunu
    May 16, 2016 at 18:25

3 Answers 3

11

This post is focusing on the server-side - ignoring the client

Option 1 - screen

I would recommend running those commands via screen.

Some details about the terminal multiplexer screen can be found here.

In short:

  • install screen on server
  • ssh to server
  • start screen and run your command inside the screen session
  • ... imagine disconnect from mobile to server for whatever reason
  • reconnect from mobile to server
  • re-attach to this screen session and enjoy the ongoing process

Option 2 - tmux

tmux is another terminal multiplexer, you can check some details via its man-page.

Option 3 - byobu

byobu is a wrapper that provides various improvements over screen. It uses screen or tmux as a backend. More info on the web page.

3
  • While not exactly an answer to the question, this is very good advice, not only when using Ubuntu Touch. It greatly helps mitigate the effects of disconnections, be it due to network problems, switching off your client device, etc. May 10, 2016 at 13:19
  • And there's byobu, which can wrap either screen or tmux
    – ryenus
    May 10, 2016 at 14:19
  • Yes. A good advice. I have already used screen years ago and will check it out again.
    – Frunu
    May 16, 2016 at 18:27
2

You can use the TweakGeek app. In the Applications menu you will find Terminal. There you can activate a switch called Prevent suspending.

I have tried to connect to SSH from the ubuntu phone's terminal to my laptop, switched app, switched back, and the connection was still alive.

That should do the trick, but as noted in other answers, a mobile phone might not get you the best SSH experience anyway.

2
  • Could you provide a link to TweakGeek, or some information on how to install it? It doesn't seem to be on the regular app store (but apparently on OpenStore). May 11, 2016 at 9:08
  • Indeed, I have installed it through the OpenStore.
    – Bastian
    May 11, 2016 at 10:38
1

There is a bigger issue waiting for you when you get past that one.

Until earlier this year there used to be support for automatically resuming momentarily dropped ssh connections but it was found to be very insecure and has been removed. This would mean that devices like mobiles that can drop connections or switch routes will be less useful for ssh from now on.

Heres the advisory https://www.qualys.com/2016/01/14/cve-2016-0777-cve-2016-0778/openssh-cve-2016-0777-cve-2016-0778.txt

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.