🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 26 (from laksa165)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

đź“„
INDEXABLE
âś…
CRAWLED
12 hours ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://embedjournal.com/screen-keep-ssh-sessions-alive-between-connections/
Last Crawled2026-04-11 10:27:40 (12 hours ago)
First Indexed2017-06-22 18:50:56 (8 years ago)
HTTP Status Code200
Meta TitleUse screen to keep SSH sessions alive between connections - EmbedJournal
Meta DescriptionFor those of you who haven’t heard about GNU Screen, it is a window manager that multiplexes a physical terminal between several processes, typically interactive shells. It allows you to start, retain, attach and detach to a session across different connections. In lay man’s terms, it’s a life saver when...
Meta Canonicalnull
Boilerpipe Text
For those of you who haven’t heard about GNU Screen , it is a window manager that multiplexes a physical terminal between several processes, typically interactive shells. It allows you to start, retain, attach and detach to a session across different connections. In lay man’s terms, it’s a life saver when you have to work on remote devices over flaky networks. It is a simple tool that does one thing and does it extremely very well. So far the only annoyance I have had with screen is its behavior when home directory encryption is enabled. But this is not all that big a deal breaker, as most people don’t turn on home directory encryption (except may be accidentally, or when they need to share the machine with some other users), they encrypt the whole drive. I spend a lot of my time on remote machines. Be it my development server, or the deployment environment all of it is done through a SSH connection to the remote host. At times, these remote hosts are across the globe on another continent. This is really where it gets super annoying, as you have to type something expect it to be there in the next 2 seconds and typos are an expensive mistake. What are we trying to solve? To give you an idea of what I am taking about, let’s say you have a development server, where you initiate a build. A clean build on my current project (when I last timed) takes little over 40 minutes and incremental builds take up to 2 minutes (for this, I believe the poor make rules are fault). Now, lets say you start a SSH connection and initiate a clean build. For the sake of this discussion we will assume that you don’t know how to keep an SSH connection alive indefinitely and your connection is interrupted. Or you were moving your laptop around and your wireless card roamed away to another SSID and you lost connection. You will notice that the make process that you initiated receives a hang-up signal and dies with your connection. One obvious and not so great way to deal with this is to start is with nohup and push it to background with a & like this. $ nohup make & This does work, in the sense that it will discard the hangup signal and persist even after the connection has ended. But it doesn’t actually help if you were editing some file or if you needed more than just one TTY. This is where screen comes into picture and far exceeds expectations. GNU Screen Your work flow will be like this, login to remote machine and then start off a screen session and then start doing your works in that session. If your connection gets interrupted, you don’t have to give a damn about it. Screen is still running in that machine. You can always ssh back to that machine and then reconnect that session to pickoff from where you left. Screen Basics The good thing about screen is, you just need to know a handful of things initially to get going. Once you’ve gotten a hang of these basic stuffs, you can always pick up more things as and when you need them. So let’s dive in. Screen is not installed by default in most distributions, so you must use apt or yum or brew to install it. Not surprisingly, you start a screen session by using the screen command on a shell. $ screen Screen key bindings Once you hit screen, you are inside a screen session. The key binding prefix for screen is Ctrl + a . Any character followed by this sequence is interpreted as a command to screen. For example, to detach from the session, you will have to press Ctrl + a , and then press d . The screen documents refer to this sequence with C-a d . This is of the form, C-a <command-character> List, attach and detach screen sessions You can You can use screen -ls to see the screen sessions that are active. Since we have started only one session so far, your output will list only one session. The following is an example of a screen listing. There is a screen on: 13866.pts-7.extrops (Sunday 11 June 2017 04:13:31 IST) (Detached) 1 Socket in /var/run/screen/S-siddharth. Currently there is only one screen running in my computer, so the listing returns only one socket. You can create as many screen sessions as you wish and when you do a screen -ls you will notice that there are more sockets listed in /var/run/screen/ . To re attach to the session we earlier detached from, you can do, $ screen -x If there are more than one screen sessions, you will not be able to do screen -x directly to attach to a session. You have to add the screen’s name to the reattach command to explicitly state which screen you want to attach to. In this case you will have to do a screen -x 13866 to reattach to that session. Screen window management The best thing about screen is, it’s ability to spawn of more than one TTY. In the same session, you can start off may windows. Screen starts one window when you create a session. After this you can use C-a c to create another. And move between those windows by using C-a C-a . Now you can be in one directory in one and another in the other window. To see the list of windows, you hit C-a " and move up and down in the list to choose one. Once you are done, you can kill that window with C-a k , you will be asked for a confirmation to kill the current window. Here is a small subset of key bindings that you need to know to get started with screen. Key Binding Description C-a c create new window C-a C-a switch between the last windows C-a NUM change to window by number, NUM C-a n change to next window in list C-a p change to previous window in list C-a “ see window list C-a k kill current window C-a \ kill all windows C-a A rename current window This is not a full list of key bindings. There is an overwhelming number of key bindings in the screen manual do have a look at it once you have internalised the basics. Customizing screen with screenrc Like vim and bash, the runtime behavior of screen can be customized with a screenrc file in the home directory. The following code block is the contents of my screenrc file, I have been using for years and it works like a charm. If you are a screen beginner, then this is a good starting point. Copy the following lines to ~/.screenrc and checkout its effects. startup_message off term screen-256color setenv LC_CTYPE en_US.UTF-8 defutf8 on setenv DISPLAY ':0' nonblock on vbell on msgwait 3 defscrollback 10000 altscreen on bind = resize = bind + resize +1 bind - resize -1 bind _ resize max bind x remove hardstatus on sorendition kw hardstatus alwayslastline hardstatus string "%{= ky}%-Lw%{=r}%20>%n %t%{= ky}%+Lw %{= ky}%-=| %{= kw}%M%d %c%{-} %{=r} ${USER}@%H " What to start screen soon after login? As you familiarize yourself with screen, you will notice that most of the time screen is the first command that you run after ssh-ing into the machine. The easiest way to achieve this is to add an exec screen -d -RR as the last line in ~/.bashrc . That works, but if there is some issue with screen and for some reason it won’t start, then adding this line prevents you from logging into your machine, causing a lot of trouble. Alternatively, you could add the machine details to your ~/.ssh/config and add a RemoteCommand section to indicate that you would like to attach-to/create a screen session after login. host my_machine HostName 10.10.10.1 User sid RequestTTY yes RemoteCommand screen -d -RR Now you could just do ssh my_machine to login to [email protected] . Neat right? A word on tmux There is one other tool—tmux—which is gaining popularity lately. I have tried using it and felt like a fish out of the pond, but I’m sure that was highly opinionated. IMHO, tmux is trying to reinvent the wheel. Why spend all the developer effort in recreating screen when such energy can be channeled to perfect it? All they have managed to achieve is to cause fragmentation in community and user base. That said, I think screen is an amazing tool, being a screen user, I still can’t think of one good reason to switch. Siddharth is a Firmware Engineer, techie, and a movie-buff. His interests include, Programming, Embedded Systems, Linux, Robotics, CV, Carpentry and a lot more. You get to know him on the following social channels. Read more about Siddharth
Markdown
Toggle navigation [![Embed Journal](https://embedjournal.com/assets/images/logo/embedjournal-120px.png)](https://embedjournal.com/) - [Archives](https://embedjournal.com/archives/) - [Embedded](https://embedjournal.com/category/embedded/) - [Microchip PIC](https://embedjournal.com/category/microchip-pic/) - [Arduino](https://embedjournal.com/category/arduino/) - [Hardware](https://embedjournal.com/category/hardware/) - [Robotics](https://embedjournal.com/category/robotics/) - [Linux](https://embedjournal.com/category/linux/) - [Programming](https://embedjournal.com/category/programming/) - [About](https://embedjournal.com/about/) - [Authors](https://embedjournal.com/authors/) - [Contact](https://embedjournal.com/contact/) - [![Embed Journal](https://embedjournal.com/assets/images/logo/embedjournal-ej.png)](https://embedjournal.com/) - [Archives](https://embedjournal.com/archives/) - [Embedded](https://embedjournal.com/category/embedded/) - [Microchip PIC](https://embedjournal.com/category/microchip-pic/) - [Arduino](https://embedjournal.com/category/arduino/) - [Hardware](https://embedjournal.com/category/hardware/) - [Robotics](https://embedjournal.com/category/robotics/) - [Linux](https://embedjournal.com/category/linux/) - [Programming](https://embedjournal.com/category/programming/) # Use screen to keep SSH sessions alive between connections [Jun 2017](https://embedjournal.com/archives/2017/06) [Siddharth](https://embedjournal.com/authors/siddharth-chandrasekaran) [Linux](https://embedjournal.com/category/linux) [Intro](https://embedjournal.com/tag/intro) , [Tools](https://embedjournal.com/tag/tools) [Print](https://embedjournal.com/screen-keep-ssh-sessions-alive-between-connections/) For those of you who haven’t heard about [GNU Screen](https://www.gnu.org/software/screen/), it is a window manager that multiplexes a physical terminal between several processes, typically interactive shells. It allows you to start, retain, attach and detach to a session across different connections. In lay man’s terms, it’s a life saver when you have to work on remote devices over flaky networks. It is a simple tool that does one thing and does it extremely very well. So far the only annoyance I have had with screen is its behavior when home directory encryption is enabled. But this is not all that big a deal breaker, as most people don’t turn on home directory encryption (except may be accidentally, or when they need to share the machine with some other users), they encrypt the whole drive. I spend a lot of my time on remote machines. Be it my development server, or the deployment environment all of it is done through a SSH connection to the remote host. At times, these remote hosts are across the globe on another continent. This is really where it gets super annoying, as you have to type something expect it to be there in the next 2 seconds and typos are an expensive mistake. ### What are we trying to solve? To give you an idea of what I am taking about, let’s say you have a development server, where you initiate a build. A clean build on my current project (when I last timed) takes little over 40 minutes and incremental builds take up to 2 minutes (for this, I believe the poor make rules are fault). Now, lets say you start a SSH connection and initiate a clean build. For the sake of this discussion we will assume that you don’t know how to keep an SSH connection alive indefinitely and your connection is interrupted. Or you were moving your laptop around and your wireless card roamed away to another SSID and you lost connection. You will notice that the make process that you initiated receives a hang-up signal and dies with your connection. One obvious and not so great way to deal with this is to start is with `nohup` and push it to background with a `&` like this. ``` $ nohup make & ``` This does work, in the sense that it will discard the hangup signal and persist even after the connection has ended. But it doesn’t actually help if you were editing some file or if you needed more than just one TTY. This is where screen comes into picture and far exceeds expectations. ## GNU Screen [![gnu screen window grab]()](https://embedjournal.com/screen-keep-ssh-sessions-alive-between-connections/) Your work flow will be like this, login to remote machine and then start off a screen session and then start doing your works in that session. If your connection gets interrupted, you don’t have to give a damn about it. Screen is still running in that machine. You can always ssh back to that machine and then reconnect that session to pickoff from where you left. ### Screen Basics The good thing about screen is, you just need to know a handful of things initially to get going. Once you’ve gotten a hang of these basic stuffs, you can always pick up more things as and when you need them. So let’s dive in. Screen is not installed by default in most distributions, so you must use `apt` or `yum` or `brew` to install it. Not surprisingly, you start a screen session by using the `screen` command on a shell. ``` $ screen ``` ### Screen key bindings Once you hit screen, you are inside a screen session. The key binding prefix for screen is `Ctrl` + `a`. Any character followed by this sequence is interpreted as a command to screen. For example, to detach from the session, you will have to press `Ctrl` + `a`, and then press `d`. The screen documents refer to this sequence with `C-a d`. This is of the form, `C-a <command-character>` ### List, attach and detach screen sessions You can You can use `screen -ls` to see the screen sessions that are active. Since we have started only one session so far, your output will list only one session. The following is an example of a screen listing. ``` There is a screen on: 13866.pts-7.extrops (Sunday 11 June 2017 04:13:31 IST) (Detached) 1 Socket in /var/run/screen/S-siddharth. ``` Currently there is only one screen running in my computer, so the listing returns only one socket. You can create as many screen sessions as you wish and when you do a `screen -ls` you will notice that there are more sockets listed in `/var/run/screen/`. To re attach to the session we earlier detached from, you can do, ``` $ screen -x ``` If there are more than one screen sessions, you will not be able to do `screen -x` directly to attach to a session. You have to add the screen’s name to the reattach command to explicitly state which screen you want to attach to. In this case you will have to do a `screen -x 13866` to reattach to that session. ### Screen window management The best thing about screen is, it’s ability to spawn of more than one TTY. In the same session, you can start off may windows. Screen starts one window when you create a session. After this you can use `C-a c` to create another. And move between those windows by using `C-a C-a`. Now you can be in one directory in one and another in the other window. To see the list of windows, you hit `C-a "` and move up and down in the list to choose one. Once you are done, you can kill that window with `C-a k`, you will be asked for a confirmation to kill the current window. Here is a small subset of key bindings that you need to know to get started with screen. | Key Binding | Description | |---|---| | C-a c | create new window | | C-a C-a | switch between the last windows | | C-a NUM | change to window by number, NUM | | C-a n | change to next window in list | | C-a p | change to previous window in list | | C-a “ | see window list | | C-a k | kill current window | | C-a \\ | kill all windows | | C-a A | rename current window | This is not a full list of key bindings. There is an overwhelming number of [key bindings in the screen manual](https://www.gnu.org/software/screen/manual/screen.html) do have a look at it once you have internalised the basics. ### Customizing screen with screenrc Like vim and bash, the runtime behavior of screen can be customized with a screenrc file in the home directory. The following code block is the contents of my screenrc file, I have been using for years and it works like a charm. If you are a screen beginner, then this is a good starting point. Copy the following lines to `~/.screenrc` and checkout its effects. ``` startup_message off term screen-256color setenv LC_CTYPE en_US.UTF-8 defutf8 on setenv DISPLAY ':0' nonblock on vbell on msgwait 3 defscrollback 10000 altscreen on bind = resize = bind + resize +1 bind - resize -1 bind _ resize max bind x remove hardstatus on sorendition kw hardstatus alwayslastline hardstatus string "%{= ky}%-Lw%{=r}%20>%n %t%{= ky}%+Lw %{= ky}%-=| %{= kw}%M%d %c%{-} %{=r} ${USER}@%H " ``` ### What to start screen soon after login? As you familiarize yourself with screen, you will notice that most of the time `screen` is the first command that you run after ssh-ing into the machine. The easiest way to achieve this is to add an `exec screen -d -RR` as the last line in `~/.bashrc`. That works, but if there is some issue with screen and for some reason it won’t start, then adding this line prevents you from logging into your machine, causing a lot of trouble. Alternatively, you could add the machine details to your `~/.ssh/config` and add a `RemoteCommand` section to indicate that you would like to attach-to/create a screen session after login. ``` host my_machine HostName 10.10.10.1 User sid RequestTTY yes RemoteCommand screen -d -RR ``` Now you could just do `ssh my_machine` to login to `[email protected]`. Neat right? ### A word on tmux There is one other tool—tmux—which is gaining popularity lately. I have tried using it and felt like a fish out of the pond, but I’m sure that was highly opinionated. IMHO, tmux is trying to reinvent the wheel. Why spend all the developer effort in recreating screen when such energy can be channeled to perfect it? All they have managed to achieve is to cause fragmentation in community and user base. That said, I think screen is an amazing tool, being a screen user, I still can’t think of one good reason to switch. [Siddharth Chandrasekaran](https://embedjournal.com/authors/siddharth-chandrasekaran) ![Sample Thumb](https://embedjournal.com/assets/images/authors/siddharth.jpg) Siddharth is a Firmware Engineer, techie, and a movie-buff. His interests include, Programming, Embedded Systems, Linux, Robotics, CV, Carpentry and a lot more. You get to know him on the following social channels. [Read more about Siddharth](https://embedjournal.com/authors/siddharth-chandrasekaran) ### Related Posts [![Installing and configuring a TFTP Server on Ubuntu](https://embedjournal.com/assets/images/categories/linux-80x80.jpg)](https://embedjournal.com/installing-configuring-a-tftp-server-ubuntu/) [Installing and configuring a TFTP Server on Ubuntu](https://embedjournal.com/installing-configuring-a-tftp-server-ubuntu/) Nov 23, 2017 [![GLEM: Graphical LCD Emulator in C](https://embedjournal.com/assets/posts/embedded/2016-06-05-glem-graphical-lcd-emulator-c/post-thumb-80x80.jpg)](https://embedjournal.com/glem-graphical-lcd-emulator-c/) [GLEM: Graphical LCD Emulator in C](https://embedjournal.com/glem-graphical-lcd-emulator-c/) Jun 5, 2016 [![Circuit Debugging - Tips Tricks & Techniques](https://embedjournal.com/assets/posts/hardware/2014-03-02-circuit-debugging-tips-tricks-techniques/post-thumb-80x80.jpg)](https://embedjournal.com/circuit-debugging-tips-tricks-techniques/) [Circuit Debugging - Tips Tricks & Techniques](https://embedjournal.com/circuit-debugging-tips-tricks-techniques/) Mar 2, 2014 [![PIC Pin Diagram, A printable copy for quick reference](https://embedjournal.com/assets/posts/microchip-pic/2013-11-16-printable-pic-18f-pin-diagram-for-rapid-prototyping/post-thumb-80x80.jpg)](https://embedjournal.com/printable-pic-18f-pin-diagram-for-rapid-prototyping/) [PIC Pin Diagram, A printable copy for quick reference](https://embedjournal.com/printable-pic-18f-pin-diagram-for-rapid-prototyping/) Nov 16, 2013 Please enable JavaScript to view the [comments powered by Disqus.](http://disqus.com/?ref_noscript) [About EmbedJournal](https://embedjournal.com/about) Embedjournal is a blog focusing on embedded software/hardware design and a bunch of other - somewhat - related things. Embedded systems play a vital role in our day-to-day lives, even without our knowledge we are using dozens of embedded devices. This journal is dedicated to all enthusiasts and hackers out there. - [Guest Blogging](https://embedjournal.com/guest-blogging/) - [Authors](https://embedjournal.com/authors) - [About](https://embedjournal.com/about/) - [Contact](https://embedjournal.com/contact/) - [Privacy](https://embedjournal.com/privacy-policy/) - [Disclaimer](https://embedjournal.com/disclaimer/) - [Sitemap](https://embedjournal.com/sitemap.xml) - [FAQ](https://embedjournal.com/faq/) © Copyright 2023 [EmbedJournal](https://embedjournal.com/) All Rights Reserved. 05052023
Readable Markdown
For those of you who haven’t heard about [GNU Screen](https://www.gnu.org/software/screen/), it is a window manager that multiplexes a physical terminal between several processes, typically interactive shells. It allows you to start, retain, attach and detach to a session across different connections. In lay man’s terms, it’s a life saver when you have to work on remote devices over flaky networks. It is a simple tool that does one thing and does it extremely very well. So far the only annoyance I have had with screen is its behavior when home directory encryption is enabled. But this is not all that big a deal breaker, as most people don’t turn on home directory encryption (except may be accidentally, or when they need to share the machine with some other users), they encrypt the whole drive. I spend a lot of my time on remote machines. Be it my development server, or the deployment environment all of it is done through a SSH connection to the remote host. At times, these remote hosts are across the globe on another continent. This is really where it gets super annoying, as you have to type something expect it to be there in the next 2 seconds and typos are an expensive mistake. ### What are we trying to solve? To give you an idea of what I am taking about, let’s say you have a development server, where you initiate a build. A clean build on my current project (when I last timed) takes little over 40 minutes and incremental builds take up to 2 minutes (for this, I believe the poor make rules are fault). Now, lets say you start a SSH connection and initiate a clean build. For the sake of this discussion we will assume that you don’t know how to keep an SSH connection alive indefinitely and your connection is interrupted. Or you were moving your laptop around and your wireless card roamed away to another SSID and you lost connection. You will notice that the make process that you initiated receives a hang-up signal and dies with your connection. One obvious and not so great way to deal with this is to start is with `nohup` and push it to background with a `&` like this. ``` $ nohup make & ``` This does work, in the sense that it will discard the hangup signal and persist even after the connection has ended. But it doesn’t actually help if you were editing some file or if you needed more than just one TTY. This is where screen comes into picture and far exceeds expectations. ## GNU Screen [![gnu screen window grab](https://embedjournal.com/assets/posts/linux/2017-06-18-screen-keep-ssh-sessions-alive-between-connections/screen_session.png)](https://embedjournal.com/screen-keep-ssh-sessions-alive-between-connections/) Your work flow will be like this, login to remote machine and then start off a screen session and then start doing your works in that session. If your connection gets interrupted, you don’t have to give a damn about it. Screen is still running in that machine. You can always ssh back to that machine and then reconnect that session to pickoff from where you left. ### Screen Basics The good thing about screen is, you just need to know a handful of things initially to get going. Once you’ve gotten a hang of these basic stuffs, you can always pick up more things as and when you need them. So let’s dive in. Screen is not installed by default in most distributions, so you must use `apt` or `yum` or `brew` to install it. Not surprisingly, you start a screen session by using the `screen` command on a shell. ``` $ screen ``` ### Screen key bindings Once you hit screen, you are inside a screen session. The key binding prefix for screen is `Ctrl` + `a`. Any character followed by this sequence is interpreted as a command to screen. For example, to detach from the session, you will have to press `Ctrl` + `a`, and then press `d`. The screen documents refer to this sequence with `C-a d`. This is of the form, `C-a <command-character>` ### List, attach and detach screen sessions You can You can use `screen -ls` to see the screen sessions that are active. Since we have started only one session so far, your output will list only one session. The following is an example of a screen listing. ``` There is a screen on: 13866.pts-7.extrops (Sunday 11 June 2017 04:13:31 IST) (Detached) 1 Socket in /var/run/screen/S-siddharth. ``` Currently there is only one screen running in my computer, so the listing returns only one socket. You can create as many screen sessions as you wish and when you do a `screen -ls` you will notice that there are more sockets listed in `/var/run/screen/`. To re attach to the session we earlier detached from, you can do, ``` $ screen -x ``` If there are more than one screen sessions, you will not be able to do `screen -x` directly to attach to a session. You have to add the screen’s name to the reattach command to explicitly state which screen you want to attach to. In this case you will have to do a `screen -x 13866` to reattach to that session. ### Screen window management The best thing about screen is, it’s ability to spawn of more than one TTY. In the same session, you can start off may windows. Screen starts one window when you create a session. After this you can use `C-a c` to create another. And move between those windows by using `C-a C-a`. Now you can be in one directory in one and another in the other window. To see the list of windows, you hit `C-a "` and move up and down in the list to choose one. Once you are done, you can kill that window with `C-a k`, you will be asked for a confirmation to kill the current window. Here is a small subset of key bindings that you need to know to get started with screen. | Key Binding | Description | |---|---| | C-a c | create new window | | C-a C-a | switch between the last windows | | C-a NUM | change to window by number, NUM | | C-a n | change to next window in list | | C-a p | change to previous window in list | | C-a “ | see window list | | C-a k | kill current window | | C-a \\ | kill all windows | | C-a A | rename current window | This is not a full list of key bindings. There is an overwhelming number of [key bindings in the screen manual](https://www.gnu.org/software/screen/manual/screen.html) do have a look at it once you have internalised the basics. ### Customizing screen with screenrc Like vim and bash, the runtime behavior of screen can be customized with a screenrc file in the home directory. The following code block is the contents of my screenrc file, I have been using for years and it works like a charm. If you are a screen beginner, then this is a good starting point. Copy the following lines to `~/.screenrc` and checkout its effects. ``` startup_message off term screen-256color setenv LC_CTYPE en_US.UTF-8 defutf8 on setenv DISPLAY ':0' nonblock on vbell on msgwait 3 defscrollback 10000 altscreen on bind = resize = bind + resize +1 bind - resize -1 bind _ resize max bind x remove hardstatus on sorendition kw hardstatus alwayslastline hardstatus string "%{= ky}%-Lw%{=r}%20>%n %t%{= ky}%+Lw %{= ky}%-=| %{= kw}%M%d %c%{-} %{=r} ${USER}@%H " ``` ### What to start screen soon after login? As you familiarize yourself with screen, you will notice that most of the time `screen` is the first command that you run after ssh-ing into the machine. The easiest way to achieve this is to add an `exec screen -d -RR` as the last line in `~/.bashrc`. That works, but if there is some issue with screen and for some reason it won’t start, then adding this line prevents you from logging into your machine, causing a lot of trouble. Alternatively, you could add the machine details to your `~/.ssh/config` and add a `RemoteCommand` section to indicate that you would like to attach-to/create a screen session after login. ``` host my_machine HostName 10.10.10.1 User sid RequestTTY yes RemoteCommand screen -d -RR ``` Now you could just do `ssh my_machine` to login to `[email protected]`. Neat right? ### A word on tmux There is one other tool—tmux—which is gaining popularity lately. I have tried using it and felt like a fish out of the pond, but I’m sure that was highly opinionated. IMHO, tmux is trying to reinvent the wheel. Why spend all the developer effort in recreating screen when such energy can be channeled to perfect it? All they have managed to achieve is to cause fragmentation in community and user base. That said, I think screen is an amazing tool, being a screen user, I still can’t think of one good reason to switch. ![Sample Thumb](https://embedjournal.com/assets/images/authors/siddharth.jpg) Siddharth is a Firmware Engineer, techie, and a movie-buff. His interests include, Programming, Embedded Systems, Linux, Robotics, CV, Carpentry and a lot more. You get to know him on the following social channels. [Read more about Siddharth](https://embedjournal.com/authors/siddharth-chandrasekaran)
Shard26 (laksa)
Root Hash228030303705352626
Unparsed URLcom,embedjournal!/screen-keep-ssh-sessions-alive-between-connections/ s443