Keep SSH Session Alive After Disconnecting
When I use SSH to remotely manage my Ubuntu servers specifically when installing applications and editing config files sometimes I get disconnected due to internet connectivity issues. Most of the time I use Hamachi VPN to connect to the servers.
If it get disconnected in middle of setting up something, there is no way to get the old terminal session back after reconnecting.
Finally I found a solution to resolve this issue by using Screen application. We can use Screen to create multiple virtual terminal session inside the terminal and it’s separated from current terminal session. So anytime you can get out of screen session and re-connect to it from a different terminal session. So it won’t die untill you exit the screen app.
To install screen simply type
sudo apt-get install screen
Following are the mostly used screen options
To create a new screen session type
To exit from screen session and go back to default session
Ctrl+A and Ctrl+D
To reconnect to screen session type
To create a new tab inside session session
Ctrl+A and Ctrl+C
To list screen tabs
Ctrl+A and Ctrl+W
To switch between screen tabs
Ctrl+A and Ctrl+A