Skip to content

OCIO y TECnología

  • Privacy Policy
Offcanvas

  • Register
  • Lost your password ?

OCIO y TECnología

  • Home » 
  • Tecnología » 
  • Linux » 
  • Detachable screens to avoid SSH disconnections

Detachable screens to avoid SSH disconnections

Emilio González Montaña 2024/06/08 0

You’re updating a server via SSH, or running other kind of vital operation that shouldn’t be interrupted in the middle, but you’re not lucky enough and the SSH connection fails or maybe you’re connected through a VPN (and “accidentally” you update the Docker engine serving the VPN, oops!).

In this kind of situations it’s better to use screen command, it allows to define kind of persistent sessions, so if SSH is disconnected for what ever reason, the SSH session will not end automatically, it will be there waiting for you to re-attach the session (screen).

Installation

Just install it with your OS package manager, for instance in Debian/Ubuntu:

$ sudo apt install screen

That’s all, you can test the version with:

$ screen --version
Screen version 4.09.00 (GNU) 30-Jan-22

Start a new screen session

You can run an unnamed screen session just running:

$ screen

All sessions will be named, but it will get and auto-generated name.

If you prefer to give it a name, run it with -S and the name, for instance if you plan to update the system:

$ screen -S update

Exit the screen session

Just run exit command, only screen session will be closed, but not the SSH connection.

Listing sessions

Run:

$ screen -ls
There is a screen on:
         2265696.pts-0.docker-03 (06/08/2024 02:52:34 PM) (Attached)
1 Socket in /run/screen/S-emilio.

If the session had name you will see this instead:

$ screen -ls
There is a screen on:
2266470.update (06/08/2024 02:55:32 PM) (Attached)
1 Socket in /run/screen/S-emilio.

Reattach to a session

To reattach run the screen command with -r and the name of the session, for unnamed sessions you will need to list the sessions before (as we did on the previous section):

$ screen -r pts-0.docker-03

If the session had name, just pass the session name as parameter:

$ screen -r update

Detach from a session

If you just want to freeze a session you can detach from it, pressing CTRL + A and then pressing D (CTRL should be previously released).

Comparte esto:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
Tags : Tags debian   Linux   screen   SSH   Ubuntu
Share
facebookShare on FacebooktwitterShare on TwitterpinterestShare on Pinterest
linkedinShare on LinkedinvkShare on VkredditShare on ReddittumblrShare on TumblrviadeoShare on ViadeobufferShare on BufferpocketShare on PocketwhatsappShare on WhatsappviberShare on ViberemailShare on EmailskypeShare on SkypediggShare on DiggmyspaceShare on MyspacebloggerShare on Blogger YahooMailShare on Yahoo mailtelegramShare on TelegramMessengerShare on Facebook Messenger gmailShare on GmailamazonShare on AmazonSMSShare on SMS
Post navigation
Previous post

Expose WSL2 port to the network

Emilio González Montaña

Related Posts

Categories Linux  Networking  Tecnología Detachable screens to avoid SSH disconnections

Expose WSL2 port to the network

Categories Data bases  Docker  Tecnología Detachable screens to avoid SSH disconnections

Recover corrupted Postgres DB WAL

Categories Tecnología Detachable screens to avoid SSH disconnections

Install kubectl on Ubuntu via APT repository

Leave a Comment Cancel reply

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

Recent Posts

  • Detachable screens to avoid SSH disconnections
  • Expose WSL2 port to the network
  • Rosaleda (parque El Retiro, Madrid)
  • Back to the painting table
  • Recover corrupted Postgres DB WAL

Categories

  • Aficiones
  • AI
  • Bricolage
  • Data bases
  • Docker
  • Escenografía
  • Eventos
  • Fotografía
  • Hardware
  • Linux
  • Networking
  • Partidas
  • Proxmox
  • Sin categoría
  • Tecnología
  • Utils
  • Viajes
  • Virtualization
  • Warhammer
  • YAML

Tags

anthill (1) apt (5) cellular-automatons (1) ceph (2) context (1) conways-life (1) cortador (1) debian (3) docker (9) docker-compose.yml (4) docker-swarm (5) DRY (1) El Imperio (2) Enanos (2) escenografía (3) fotos (3) GlusterFS (1) Guerreros del Caos (2) informática (1) Linux (8) M.2 (1) Mac (1) Madrid (2) maqueta (2) MariaDB (2) miniaturas (4) MySQL (2) NFS (2) NVMe (1) partida (2) poliestireno (1) portainer (1) proxmox (2) rocas (1) Sony A65 (2) SSH (5) ssh-key (1) Ubuntu (8) update (2) volume (1) Warhammer (11) Windows (3) WSL (2) WSL2 (2) YAML (1)

Archives

  • June 2024
  • May 2024
  • April 2024
  • February 2024
  • January 2024
  • September 2023
  • August 2023
  • June 2023
  • December 2021
  • April 2021
  • May 2020
  • April 2020
  • March 2020
  • November 2019
  • July 2018
  • February 2017
  • June 2015
  • April 2014
  • April 2011
  • January 2011
  • July 2010
  • June 2010
  • March 2010
  • November 2009
  • June 2009
  • December 2008
  • November 2008
  • October 2008
  • June 2008
  • May 2008
  • October 2007

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Copyright © 2025 OCIO y TECnología - Powered by Nevothemes.
Offcanvas