LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-14-2017, 02:13 PM   #1
dediganss
LQ Newbie
 
Registered: Jul 2017
Posts: 10

Rep: Reputation: Disabled
Why is Screen closing all detached screens after I close my SSH Client (Putty)


Hi everybody,
So, I started I little project in Debian with my friends. We suposed to run a wowserver to play together and remember the old times. Long history short.
First we where using a Mint linux in another VPS provider. But because of high ping, we changed. This vps uses Debian 8.7. Same hardware as the other one.
I installed everything in the same way.
I run screen -AmdS to start the server (It needs 2 windows to work)
Everything fine, screen -ls show both screens detached from session.
By the minute I type exit or close the SSH client (Putty in my case), the screens are instantly terminated. Everyone gots DC.
I used to do the same commands in the other VPS, I could just close putty, relog putty, type screen -ls and the screens would be there.
I don't know how to configure my new vps to work like that, I don't know what can be causing that. After days of google research, heres a small list of stuff i tried:
nohup (Don't know how to use properly, followed some tips, no deal)
tmux
disown
screen (offcourse)
add session timeout line in sshd_conf (+ssh_conf)

Old system information uname -a
Linux vps58ed942a796dd 2.6.32-042stab123.1 #1 SMP Wed Mar 22 15:21:30 MSK 2017 x86_64 GNU/Linux

New system information uname -a
Linux vps3755 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2+deb8u2 (2017-06-26) x86_64 GNU/Linux.
Hope anyone can help, It kinda sux need my laptop on to keep a server running in another machine.(And pointless)

Last edited by dediganss; 07-16-2017 at 07:31 PM.
 
Old 07-14-2017, 03:22 PM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,086
Blog Entries: 3

Rep: Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665
The output from "lsb_release -rd" would help more, but since you mention Debian 8.x you're using a version with systemd. systemd kills all your processes on the way out unless the system has been configured to restore the normal behavior of not killing them. It kills even the ones you've told to stay with nohup and such. If it is the case that systemd is killing your processes, then you'll have to look for the right place to put "KillUserProcesses=no" or some other mitigation.
 
1 members found this post helpful.
Old 07-14-2017, 08:33 PM   #3
dediganss
LQ Newbie
 
Registered: Jul 2017
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
The output from "lsb_release -rd" would help more, but since you mention Debian 8.x you're using a version with systemd. systemd kills all your processes on the way out unless the system has been configured to restore the normal behavior of not killing them. It kills even the ones you've told to stay with nohup and such. If it is the case that systemd is killing your processes, then you'll have to look for the right place to put "KillUserProcesses=no" or some other mitigation.
Description: Debian GNU/Linux 8.8 (jessie)
Release: 8.8
lsb_release -rd.

about "KillUserProcesses=no"

nano /etc/systemd/logind.conf
went here, and actually there was a #KillUserProcesses=no
So I removed the #, saved the file and reboot the system (Because this is the way I think changes are applied)
started screen -AmdS server
Closed putty, and the processes died.
 
Old 07-15-2017, 01:01 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,086
Blog Entries: 3

Rep: Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665
That might have to be set via one of their own tools, such as loginctl
https://www.freedesktop.org/software...#enable-linger
I'm not sure though. I use Devuan nowadays where I used Debian and don't have Debian anywhere any more beccause of systemd.

What happens when you try to manually control systemd when you run tmux or screen in a detached session before logging out?

Code:
systemd-run --scope --user  screen -AmdS server
or

Code:
systemd-run --scope --user  tmux new-session -Ads server
When you re-connect to the machine are the sessions still there?
 
Old 07-15-2017, 04:23 AM   #5
dediganss
LQ Newbie
 
Registered: Jul 2017
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
That might have to be set via one of their own tools, such as loginctl
https://www.freedesktop.org/software...#enable-linger
I'm not sure though. I use Devuan nowadays where I used Debian and don't have Debian anywhere any more beccause of systemd.

What happens when you try to manually control systemd when you run tmux or screen in a detached session before logging out?

Code:
systemd-run --scope --user  screen -AmdS server
or

Code:
systemd-run --scope --user  tmux new-session -Ads server
When you re-connect to the machine are the sessions still there?
Failed to create bus connection: Connection refused

when I try to start with both commands.
loginctl list-sessions
0 sessions listed.
loginctl list-users
0 users listed.
loginctl list-seats
seat0

Don't trying anything, because is a unknow territory for me, don't want to screw up anything.
 
Old 07-16-2017, 01:14 PM   #6
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 814

Rep: Reputation: 265Reputation: 265Reputation: 265
Have you tried disconnecting from the screen session before closing Putty? (CTRL+a d)

EDIT: Realized you already are doing that
 
Old 07-16-2017, 02:26 PM   #7
dediganss
LQ Newbie
 
Registered: Jul 2017
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by maples View Post
Have you tried disconnecting from the screen session before closing Putty? (CTRL+a d)

EDIT: Realized you already are doing that
Yes.
What I realized so far is that systemd is killing my session or process. But I don't know how to configure it to avoid this behavior.
 
Old 07-16-2017, 02:54 PM   #8
TheEzekielProject
Member
 
Registered: Dec 2016
Distribution: arch
Posts: 668

Rep: Reputation: 190Reputation: 190
You might find this link relevant.

Basically someone filed this as a bug with Debian and the response was that this was a feature of systemd and not a bug. Though it changed traditionally default behavior.

Anyway, they say that setting "KillUserProcesses=no" in logind.conf and to enable "lingering" via loginctl will restore this functionality


From the loginctl manpages it looks like running
Code:
loginctl enable-linger
should do it. And then you will probably need to restart the service for it to work
Code:
systemctl restart systemd-logind

Last edited by TheEzekielProject; 07-16-2017 at 03:00 PM.
 
Old 07-16-2017, 04:08 PM   #9
dediganss
LQ Newbie
 
Registered: Jul 2017
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TheEzekielProject View Post
You might find this link relevant.

Basically someone filed this as a bug with Debian and the response was that this was a feature of systemd and not a bug. Though it changed traditionally default behavior.

Anyway, they say that setting "KillUserProcesses=no" in logind.conf and to enable "lingering" via loginctl will restore this functionality


From the loginctl manpages it looks like running
Code:
loginctl enable-linger
should do it. And then you will probably need to restart the service for it to work
Code:
systemctl restart systemd-logind
In logind.conf it was already KillUserProcess=no (With #) I don't know if I should keep the # or remove it.

The loginctl enable-linger root? Is that right? If I type without root it says to few arguments.
 
Old 07-16-2017, 04:15 PM   #10
TheEzekielProject
Member
 
Registered: Dec 2016
Distribution: arch
Posts: 668

Rep: Reputation: 190Reputation: 190
Yes, I would remove the "#" to enable that option. And yes, you would enter your username
 
Old 07-16-2017, 05:04 PM   #11
dediganss
LQ Newbie
 
Registered: Jul 2017
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TheEzekielProject View Post
Yes, I would remove the "#" to enable that option. And yes, you would enter your username
Just tried it, still not working.
After reading the link you posted, I read something about systemd-run. But still not figured out how it works
lingering is enable, the options to kill processes is deactivated, the service was restarted. No success.
 
Old 07-16-2017, 06:59 PM   #12
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,406
Blog Entries: 8

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
Quote:
Originally Posted by dediganss View Post
Just tried it, still not working.
After reading the link you posted, I read something about systemd-run. But still not figured out how it works
lingering is enable, the options to kill processes is deactivated, the service was restarted. No success.
I'll experiment with this at some point, since I use Debian on all of my computers (but I don't use screen yet).

One thing to clarify the previous advice is:

Whenever you modify /etc/systemd/logind.conf, you must run the following for the changes to be used:

Code:
systemctl restart systemd-logind.service
Your confusion about "#" is that "#" comments out code. That way, a lot of example lines can be included in a config file without actually having them do anything at all. The basic idea is that you can uncomment the line by removing the "#", and also modify the line if desired.

If you don't already know this, then it can look confusing.

Also, in some config files, position is important. There are sometimes lines that look like [XDMCPServer] or something, which specify that the following lines only apply to XDMCPServer
or something. If you modify or put lines after one of those, they will only apply to something you don't expect and will not modify what you want.

However, in /etc/systemd/logind.conf, there is only one such section. Therefore, it is unlikely that you have the position wrong. So long as your customized configuration lines are after the [Login] line, it should be good.
 
Old 07-16-2017, 07:31 PM   #13
dediganss
LQ Newbie
 
Registered: Jul 2017
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by IsaacKuo View Post
I'll experiment with this at some point, since I use Debian on all of my computers (but I don't use screen yet).

One thing to clarify the previous advice is:

Whenever you modify /etc/systemd/logind.conf, you must run the following for the changes to be used:

Code:
systemctl restart systemd-logind.service
Your confusion about "#" is that "#" comments out code. That way, a lot of example lines can be included in a config file without actually having them do anything at all. The basic idea is that you can uncomment the line by removing the "#", and also modify the line if desired.

If you don't already know this, then it can look confusing.

Also, in some config files, position is important. There are sometimes lines that look like [XDMCPServer] or something, which specify that the following lines only apply to XDMCPServer
or something. If you modify or put lines after one of those, they will only apply to something you don't expect and will not modify what you want.

However, in /etc/systemd/logind.conf, there is only one such section. Therefore, it is unlikely that you have the position wrong. So long as your customized configuration lines are after the [Login] line, it should be good.
Thanks for all explanation. After hours of reading I managed to solve it. I actually dont know how, because I did so many things (All in this post also)
But the last thing I did and solved (After removing the #, enable lingering) was:
apt-get install libpam-systemd dbus
grep -i UsePAM /etc/ssh/sshd_config
systemd-run --scope --user myservicehere (exactly like the first guys said, but It was notworking because of this libpam-systemd dbus and UsePAm seting).
Thanks everyone for the help, hope this helps the others.
 
1 members found this post helpful.
Old 07-17-2017, 12:59 AM   #14
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,086
Blog Entries: 3

Rep: Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665
Thanks for the followup post with your solution. It is interesting to know. It sure is annoying that its promoters get away with calling it an init system. For my tastes that utility has too many scope and design flaws, not just bugs, so I moved to Devuan. You might consider it for future projects. It's mostly a seemless transition from Jessie. Aside from being free of systemd it is identical to Debian GNU/Linux. (No kFreeBSD yet)

I see there is another, old thread about systemd still active that you may want to visit.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen terminating after closing SSH client. dediganss Linux - Newbie 1 07-14-2017 02:39 PM
LXer: PuTTY SSH Client And Telnet Client LXer Syndicated Linux News 0 05-14-2017 02:21 PM
[SOLVED] bitvise and/or putty client with SSH server mtdew3q Linux - Server 2 02-23-2014 10:24 AM
ssh-client gui similar to putty? matiasar Linux - Software 3 11-23-2006 11:33 AM
ssh and using putty from the client ashley75 Linux - General 12 09-11-2003 02:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration