Sshd starts two processes, but systemd stops only oneNetstat shows two sshd's listening, but only one pidCygwin sshd service starts but only produces errorsWhy does sshd(openssh) create two processes per connection?Suddenly mysql/mariadb won't startEnabling WiredTiger engine in MongoDB 3I can no longer SSH to a VM on GCP after breaking ssh configurationexecstop mysql error on stop and restartRHEL 7 service kicks in immediatelyConfiguring MySQL to Listen for Remote Connections on UbuntuDisabling systemd messages that interfere with running BASH script

Why did this prime-sequence puzzle not work?

What are the problems in teaching guitar via Skype?

Is CD audio quality good enough for the final delivery of music?

Is my router's IP address really public?

How to capture more stars?

What is the 中 in ダウンロード中?

How to make and automatically have left and right

1960s sci-fi novella with a character who is treated as invisible by being ignored

Can a Beholder use rays in melee range?

Different PCB color ( is it different material? )

Plot exactly N bounce of a ball

Why does the 6502 have the BIT instruction?

What is the most important source of natural gas? coal, oil or other?

Could I be denied entry into Ireland due to medical and police situations during a previous UK visit?

Why colon to denote that a value belongs to a type?

How is character development a major role in the plot of a story

Draw a checker pattern with a black X in the center

Windows 10 Programs start without visual Interface

Ticket sales for Queen at the Live Aid

Do you play the upbeat when beginning to play a series of notes, and then after?

Is there any use case for the bottom type as a function parameter type?

What's the connection between "kicking a pigeon" and "how a bill becomes a law"?

Smart people send dumb people to a new planet on a space craft that crashes into a body of water

Is it possible to change original filename of an exe?



Sshd starts two processes, but systemd stops only one


Netstat shows two sshd's listening, but only one pidCygwin sshd service starts but only produces errorsWhy does sshd(openssh) create two processes per connection?Suddenly mysql/mariadb won't startEnabling WiredTiger engine in MongoDB 3I can no longer SSH to a VM on GCP after breaking ssh configurationexecstop mysql error on stop and restartRHEL 7 service kicks in immediatelyConfiguring MySQL to Listen for Remote Connections on UbuntuDisabling systemd messages that interfere with running BASH script






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















There is on the linux mint 18.3 sshd (7.2p2) starts with two processes. But when I run service ssh stop only child process stops and parent process is still run. So when I restart ssh service it can't bind 22 port and became unable to receive connections.



I read about privilege separation and I think it's good despite other linuxes (for example Ubuntu) creates only one process. But why does parent process not stop when child process is stopped? And how to make systemd stop both processes?



ssh.service



[Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run

[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify

[Install]
WantedBy=multi-user.target
Alias=sshd.service


multi-user.target



# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Multi-User System
Documentation=man:systemd.special(7)
Requires=basic.target
Conflicts=rescue.service rescue.target
After=basic.target rescue.service rescue.target
AllowIsolate=yes


service ssh status



service ssh status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Чт 2019-05-16 16:53:10 MSK; 6 days ago
Process: 4535 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 4538 (sshd)
Tasks: 2
Memory: 16.4M
CPU: 3.143s
CGroup: /system.slice/ssh.service
├─4538 /usr/sbin/sshd -D
└─4539 /usr/sbin/sshd -D









share|improve this question
























  • can you post ssh process with sshd systemd target file?

    – asktyagi
    May 21 at 4:16











  • @asktyagi, I added it to question

    – abr_stackoverflow
    May 22 at 15:33











  • [Service] Type=notify EnvironmentFile=/etc/sysconfig/sshd ExecStart=/usr/sbin/sshd -D $OPTIONS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=42s Can you please try to replace your service section with above lines and restart service? take backup of your file first.

    – asktyagi
    May 22 at 16:38












  • Unfortunately your advice didn't help. There was error on the strtup. I found simplier resolution. I write it to the answer.

    – abr_stackoverflow
    May 23 at 15:56

















1















There is on the linux mint 18.3 sshd (7.2p2) starts with two processes. But when I run service ssh stop only child process stops and parent process is still run. So when I restart ssh service it can't bind 22 port and became unable to receive connections.



I read about privilege separation and I think it's good despite other linuxes (for example Ubuntu) creates only one process. But why does parent process not stop when child process is stopped? And how to make systemd stop both processes?



ssh.service



[Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run

[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify

[Install]
WantedBy=multi-user.target
Alias=sshd.service


multi-user.target



# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Multi-User System
Documentation=man:systemd.special(7)
Requires=basic.target
Conflicts=rescue.service rescue.target
After=basic.target rescue.service rescue.target
AllowIsolate=yes


service ssh status



service ssh status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Чт 2019-05-16 16:53:10 MSK; 6 days ago
Process: 4535 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 4538 (sshd)
Tasks: 2
Memory: 16.4M
CPU: 3.143s
CGroup: /system.slice/ssh.service
├─4538 /usr/sbin/sshd -D
└─4539 /usr/sbin/sshd -D









share|improve this question
























  • can you post ssh process with sshd systemd target file?

    – asktyagi
    May 21 at 4:16











  • @asktyagi, I added it to question

    – abr_stackoverflow
    May 22 at 15:33











  • [Service] Type=notify EnvironmentFile=/etc/sysconfig/sshd ExecStart=/usr/sbin/sshd -D $OPTIONS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=42s Can you please try to replace your service section with above lines and restart service? take backup of your file first.

    – asktyagi
    May 22 at 16:38












  • Unfortunately your advice didn't help. There was error on the strtup. I found simplier resolution. I write it to the answer.

    – abr_stackoverflow
    May 23 at 15:56













1












1








1


1






There is on the linux mint 18.3 sshd (7.2p2) starts with two processes. But when I run service ssh stop only child process stops and parent process is still run. So when I restart ssh service it can't bind 22 port and became unable to receive connections.



I read about privilege separation and I think it's good despite other linuxes (for example Ubuntu) creates only one process. But why does parent process not stop when child process is stopped? And how to make systemd stop both processes?



ssh.service



[Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run

[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify

[Install]
WantedBy=multi-user.target
Alias=sshd.service


multi-user.target



# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Multi-User System
Documentation=man:systemd.special(7)
Requires=basic.target
Conflicts=rescue.service rescue.target
After=basic.target rescue.service rescue.target
AllowIsolate=yes


service ssh status



service ssh status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Чт 2019-05-16 16:53:10 MSK; 6 days ago
Process: 4535 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 4538 (sshd)
Tasks: 2
Memory: 16.4M
CPU: 3.143s
CGroup: /system.slice/ssh.service
├─4538 /usr/sbin/sshd -D
└─4539 /usr/sbin/sshd -D









share|improve this question
















There is on the linux mint 18.3 sshd (7.2p2) starts with two processes. But when I run service ssh stop only child process stops and parent process is still run. So when I restart ssh service it can't bind 22 port and became unable to receive connections.



I read about privilege separation and I think it's good despite other linuxes (for example Ubuntu) creates only one process. But why does parent process not stop when child process is stopped? And how to make systemd stop both processes?



ssh.service



[Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run

[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify

[Install]
WantedBy=multi-user.target
Alias=sshd.service


multi-user.target



# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Multi-User System
Documentation=man:systemd.special(7)
Requires=basic.target
Conflicts=rescue.service rescue.target
After=basic.target rescue.service rescue.target
AllowIsolate=yes


service ssh status



service ssh status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Чт 2019-05-16 16:53:10 MSK; 6 days ago
Process: 4535 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 4538 (sshd)
Tasks: 2
Memory: 16.4M
CPU: 3.143s
CGroup: /system.slice/ssh.service
├─4538 /usr/sbin/sshd -D
└─4539 /usr/sbin/sshd -D






linux ssh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 22 at 15:33







abr_stackoverflow

















asked May 15 at 7:34









abr_stackoverflowabr_stackoverflow

160111




160111












  • can you post ssh process with sshd systemd target file?

    – asktyagi
    May 21 at 4:16











  • @asktyagi, I added it to question

    – abr_stackoverflow
    May 22 at 15:33











  • [Service] Type=notify EnvironmentFile=/etc/sysconfig/sshd ExecStart=/usr/sbin/sshd -D $OPTIONS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=42s Can you please try to replace your service section with above lines and restart service? take backup of your file first.

    – asktyagi
    May 22 at 16:38












  • Unfortunately your advice didn't help. There was error on the strtup. I found simplier resolution. I write it to the answer.

    – abr_stackoverflow
    May 23 at 15:56

















  • can you post ssh process with sshd systemd target file?

    – asktyagi
    May 21 at 4:16











  • @asktyagi, I added it to question

    – abr_stackoverflow
    May 22 at 15:33











  • [Service] Type=notify EnvironmentFile=/etc/sysconfig/sshd ExecStart=/usr/sbin/sshd -D $OPTIONS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=42s Can you please try to replace your service section with above lines and restart service? take backup of your file first.

    – asktyagi
    May 22 at 16:38












  • Unfortunately your advice didn't help. There was error on the strtup. I found simplier resolution. I write it to the answer.

    – abr_stackoverflow
    May 23 at 15:56
















can you post ssh process with sshd systemd target file?

– asktyagi
May 21 at 4:16





can you post ssh process with sshd systemd target file?

– asktyagi
May 21 at 4:16













@asktyagi, I added it to question

– abr_stackoverflow
May 22 at 15:33





@asktyagi, I added it to question

– abr_stackoverflow
May 22 at 15:33













[Service] Type=notify EnvironmentFile=/etc/sysconfig/sshd ExecStart=/usr/sbin/sshd -D $OPTIONS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=42s Can you please try to replace your service section with above lines and restart service? take backup of your file first.

– asktyagi
May 22 at 16:38






[Service] Type=notify EnvironmentFile=/etc/sysconfig/sshd ExecStart=/usr/sbin/sshd -D $OPTIONS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=42s Can you please try to replace your service section with above lines and restart service? take backup of your file first.

– asktyagi
May 22 at 16:38














Unfortunately your advice didn't help. There was error on the strtup. I found simplier resolution. I write it to the answer.

– abr_stackoverflow
May 23 at 15:56





Unfortunately your advice didn't help. There was error on the strtup. I found simplier resolution. I write it to the answer.

– abr_stackoverflow
May 23 at 15:56










1 Answer
1






active

oldest

votes


















0














Systemd option "KillMode" has option "mixed":



If set to mixed, the SIGTERM signal (see below) is sent to the main process while the subsequent SIGKILL signal (see below) is sent to all remaining processes of the unit's control group



Besides "KillMode" has another option "control-group"



If set to control-group, all remaining processes in the control group of this unit will be killed on unit stop (for services: after the stop command is executed, as configured with ExecStop=)



So I just find which of them use oftener in all service files, it's "mixed" and I just replace "KillMode=process" to "KillMode=mixed".






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "2"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f967325%2fsshd-starts-two-processes-but-systemd-stops-only-one%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Systemd option "KillMode" has option "mixed":



    If set to mixed, the SIGTERM signal (see below) is sent to the main process while the subsequent SIGKILL signal (see below) is sent to all remaining processes of the unit's control group



    Besides "KillMode" has another option "control-group"



    If set to control-group, all remaining processes in the control group of this unit will be killed on unit stop (for services: after the stop command is executed, as configured with ExecStop=)



    So I just find which of them use oftener in all service files, it's "mixed" and I just replace "KillMode=process" to "KillMode=mixed".






    share|improve this answer



























      0














      Systemd option "KillMode" has option "mixed":



      If set to mixed, the SIGTERM signal (see below) is sent to the main process while the subsequent SIGKILL signal (see below) is sent to all remaining processes of the unit's control group



      Besides "KillMode" has another option "control-group"



      If set to control-group, all remaining processes in the control group of this unit will be killed on unit stop (for services: after the stop command is executed, as configured with ExecStop=)



      So I just find which of them use oftener in all service files, it's "mixed" and I just replace "KillMode=process" to "KillMode=mixed".






      share|improve this answer

























        0












        0








        0







        Systemd option "KillMode" has option "mixed":



        If set to mixed, the SIGTERM signal (see below) is sent to the main process while the subsequent SIGKILL signal (see below) is sent to all remaining processes of the unit's control group



        Besides "KillMode" has another option "control-group"



        If set to control-group, all remaining processes in the control group of this unit will be killed on unit stop (for services: after the stop command is executed, as configured with ExecStop=)



        So I just find which of them use oftener in all service files, it's "mixed" and I just replace "KillMode=process" to "KillMode=mixed".






        share|improve this answer













        Systemd option "KillMode" has option "mixed":



        If set to mixed, the SIGTERM signal (see below) is sent to the main process while the subsequent SIGKILL signal (see below) is sent to all remaining processes of the unit's control group



        Besides "KillMode" has another option "control-group"



        If set to control-group, all remaining processes in the control group of this unit will be killed on unit stop (for services: after the stop command is executed, as configured with ExecStop=)



        So I just find which of them use oftener in all service files, it's "mixed" and I just replace "KillMode=process" to "KillMode=mixed".







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 23 at 15:59









        abr_stackoverflowabr_stackoverflow

        160111




        160111



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Server Fault!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f967325%2fsshd-starts-two-processes-but-systemd-stops-only-one%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

            Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

            What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company