0

I use putty to login to the server via ssh. This creates a session locally; meaning if I disconnect from putty, the session is lost.

Is there any way that the session can keep running and be accessible from putty or any other client ? Or is there any other protocol or tool which can help out in this?

Michael Homer
  • 76,565
ganesh
  • 35

2 Answers2

2

The tool screen is the tool that could help you. It executes a new shell. This new shell is not killed when the terminal is disconnected and it is possible to attach to this shell after reconnection. The usage for keeping session across terminal connections is easy. To start a new session type

 $ screen

Now you can terminate the putty. When you reconnect the you can attach to the existing session

$ screen -r

Actually the screen is able to do much more. See https://www.gnu.org/software/screen/manual/screen.html

0

If you really want to prevent local disconnection from putty to prevent your ssh connection from being lost, you can install tmux (or screen) under cygwin and start putty from there. This allows you to disconnect from putty (by disconnecting from tmux) and continue to use the existing ssh connection after reconnecting (to tmux`). This assumes you can start putty from the commandline. If not you should use an ssh-client that can.

That doesn't prevent a dropped ssh connection from happening, so make sure you set at least TCPKeepAlive and a reasonable ServerAliveInterval.

In addition I would run tmux on the server side so you can reconnect to the commandline program (shell or whatever you are running), after the connection goes down in spite of other precautions (network down etc). Just this latter might be enough for your needs, as it allows reconnection to the session on the server. The local session to putty, and maintaining the ssh connection is (which is not guaranteed anyway), is normally much less interesting.

Anthon
  • 79,293