Table of Contents

Intro

On Linux, we sometimes need to check on what hashcat is doing via SSH. By default, you can't reaattach to the same console terminal (tty1, tty2 etc.) that was used to start a process. However, there is a secure option for doing this called screen.

Requirements

This example will only cover Ubuntu, as it is the distribution most commonly used by beginners.

1. Download and install Ubuntu: http://www.ubuntu.com/download

2. Install the SSH client / server:

  sudo apt-get install openssh-server openssh-client

3. Install screen:

  sudo apt-get install screen

Usage

Usage of screen is very simple. If you plan to use screen to detach from a running process, you should start screen before starting any other processes (such as a GPGPU application like hashcat). After screen starts, you will be placed in a virtual console with its own PID. To create a new virtual terminal with a specific name, enter:

screen -S [name]

To detach from a running virtual terminal, we use:

CTRL+A D

To reaattach to a detached virtual terminal (assuming that have only one virtual terminal running):

screen -x

If running more than one virtual terminal, we need to know either its PID, or the name that you chose when invoking screen -x. If more than one screen is running, screen -x will display something like:

There are several suitable screens on:
	19814.pts-0.sl1	(09/19/11 15:28:06)	(Detached)
	12239.pts-0.sl1	(09/10/11 15:02:29)	(Detached)
	1942.name	(09/10/11 17:05:40)	(Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.

By reviewing the start time, the PID, or the name of the desired terminal, we can identify the screen to be reattached. For example, if we want to reattach to the first terminal in the list above, we can either run:

screen -r 19814

or

screen -x name

Alternatives

tmux is similar to screen and has some compelling additional features.

Conclusion

Using screen not only allows you to attach to an already-running terminal, but it also eliminates the possibility of data loss or unexpected termination of your process.

If you are using unstable connection, (GPRS, WiMax), when communication is interrupted, directly attached processes will be terminated. But f you are using screen, if you are disconnected, you can simply SSH back into the system and reattach to your terminal.