LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   screen command leaves pid open on ssh server (https://www.linuxquestions.org/questions/linux-software-2/screen-command-leaves-pid-open-on-ssh-server-748643/)

manwithaplan 08-19-2009 03:20 AM

screen command leaves pid open on ssh server
 
I reverse tunnel from a notebook to a ssh server.

A script runs at startup and opens tunnel no problem. Except when the notebook is shutdown, the tunnels ssh pid stays open on the server. It results in a port forwarding error whenever the notebook restarts, because the port is still open and is reserved on the ssh server.

Example on the ssh server:


Code:

tcp        0      0 0.0.0.0:9874            0.0.0.0:*              LISTEN    9021/1
So this pid stays open even when the notebook shuts down or restarts. This is all invoked by the notebook script.

Notebook command:

Code:

screen -d -m ssh server.com -l username -R <port>:127.0.0.1:22
This means I have to kill the pid manually on the ssh server before the notebook can ssh again after any restart.

Is my screen commands wrong..?

raskin 08-19-2009 04:10 AM

I think you want to put 'autodetach off' into .screenrc on server.

manwithaplan 08-19-2009 05:07 AM

The screen is used on the notebook not the server ( I guess I don't understand screen well enough) :(

What I did is added "autodetach off" to ~/.screenrc of the notebook. And then restarted the notebook.

Then
Code:

netstat -anp | grep :<port>
on the server to see if it had killed the pid that the notebook opened, and it was still listening on the port with the same pid.

So again I had to kill the pid on the server quickly. Before the notebook script executed on startup.


All times are GMT -5. The time now is 11:53 AM.