Needrestart behaves differently when controlled without using a manual ssh connection

I am trying to run the needrestart tool to check processes with outdated libraries. When I run needstart with commands or shell modules from the impossible, it says that I need to restart my ssh daemon. When I start requirerestart manually, it says that there are no processes with obsolete libraries.

When I restart the ssh daemon, it does not matter. But after rebooting the remote server, the ssh daemon is not listed as a service that I have to restart.

So I really don’t understand the difference between ansible ssh connection and my ssh connection, which causes different needrestart behavior.

Any help would be appreciated!

Thanks in advance and best regards
Max

My local machine

$ python -V Python 2.7.13 $ ansible --version ansible 2.2.0.0 $ cat ansible.cfg [defaults] inventory = hosts ask_vault_pass = True retry_files_enabled = False 

I am using ssh proxy to connect to the server:

 ansible_ssh_common_args='-o ProxyCommand="ssh -W %h:%p -q user@jumphost.example.com "' 

Remote server

 $ cat /etc/debian_version 8.6 $ python -V Python 2.7.9 

Using affordable

 $ ansible example.com -m command -a 'needrestart -b -l -rl' Vault password: example.com | SUCCESS | rc=0 >> NEEDRESTART-VER: 1.2 NEEDRESTART-SVC: ssh.service $ ansible example.com -m shell -a 'needrestart -b -l -rl' Vault password: example.com | SUCCESS | rc=0 >> NEEDRESTART-VER: 1.2 NEEDRESTART-SVC: ssh.service 

Using ssh

 $ ssh example.com 'needrestart -b -l -rl' NEEDRESTART-VER: 1.2 Killed by signal 1. 
+5
source share
1 answer

It looks like you have an active connection to the old version of the ssh process. When ssh reboots, it does not terminate the current copies that keep active connections. If this happens, then ssh servers sudo service ssh restart will kill the active connection and you will have a broken server.

So, when you do systemctl restart sshd , you only restart ssh-part, which accepts a new connection. All existing connections are served by old ssh.

Why is it possible to maintain an ssh-ssh-ssh connection between runs? Due to the ControlMaster function. It maintains an active ssh connection between runs to speed up new runs.

What to do? Close active ssh connections on your computer. Try ps aux|grep ssh and you will see the process that serves as ControlMaster. Kill him and the outdated connection should be closed.

0
source

Source: https://habr.com/ru/post/1262710/


All Articles