Persistent PuTTY sessions for multiple windows

gnu-screenpersistentputtyssh

I'm working in various Linux environments through PuTTY connections which break from time to time. I'm looking for a solution to make the PuTTY windows persist (e.g. if I was editing a file, then after reconnecting I should be in the same editor with the same file open at the same place), with the following requirements:

  • it shouldn't require any manual setup at the beginning of the session or after reconnection (I don't want to type in screen or anything like that)
  • I have several windows open to the same machine with the same user, which tend to disconnect at the same time
  • the number/role of windows is not constant (it's not like I have an mc window, a mysql window and a "script runner" window; sometimes I use one window for search or for SVN commands, other times I need several at the same time)
  • sometimes I need to change the properties of the windows for a task (large window for grepping/editing, small windows because I need to see two of them at the same time, red background because I am modifying the live database in MySQL etc), so I need to get the same console back in the same window after a reconnect

Is there a way to achieve this? I suppose I should use screen or something equivalent, but how does it know which window I am reconnecting from? Is there some way to pass a unique window identifier to the shell from PuTTY?

Best Answer

The quick and clean solution

Edit your ~/.bashrc to run screen -r. Then you will be reattached to a running screen session automatically when you log in.

The fulfilling solution

  • Create a user for each screen session (Windows-window/PuTTY session) you intend to have open as a maximum.
  • Connect to the server using each of the newly created users and run "screen -S username" to start a session named with their username.
  • Append "screen -r $(whoami)" to each user's ~/.bashrc
  • Save a putty session for each of the users on your desktop or in PuTTY to add them to your superbar's jumplist or wherever you want your shortcuts, and use them to start up each session. This will also enable you to

EDIT: I would preferrably focus on fixing the timeout issue. It's a security feature, I know, but it shouldn't disconnect you while you are sending input.

Related Question