By default, a SSH session close in case of network disconnection, killing automatically any and all software currently running. This guide use the “byobu” software render SSH sessions persistent during disconnections.

This howto is tested on:

  • Debian 10.0 Buster


Provide the username for which SSH sessions are to be persistent:



Detect if sudo is available (“command” is used if not):

command type -f 'sudo' &>'/dev/null' && cmdProxy='sudo'

Fetch the chosen user home path:

userPath="$(command getent 'passwd' "${username}" | command cut -d':' -f6)"

Environment setup

Install the software’s requirements:

${cmdProxy} apt install 'byobu' 'vlock' 'sudo'


Enable persistent SSH sessions for the chosen user:

sudo -u "${username}" byobu-launcher-install

For additional security, setup the SSH session to be locked by a password after a 5 minutes inactivity:

sudo -u "${username}" tee -a "${userPath}/.byobu/.tmux.conf" \
  <<< 'set-option -g lock-command vlock
set-option -g lock-after-time 300'

The chosen user’s next SSH session will be persistent between network disconnections.


Categories: Setup


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.