Upgrading openssh-server within an ssh session

Suppose that you issue apt-get upgrade from an ssh session and one of the packages to be upgraded is openssh-server.

Is the new sshd process restarted after the upgrade? If yes how is the session maintained? If not, should I explicitly restart it or is there something I am missing?


Solution 1:

When you connect in something like this happens

[user@an02-east ~]$ ps aux | grep ssh
root     13789  0.0  0.0  98932  3888 ?        Ss   03:16   0:00 sshd: user [priv]
502      13791  0.0  0.0  98932  1740 ?        S    03:17   0:00 sshd: user@pts/0
root     15378  0.0  0.0  64728  1168 ?        Ss   04:13   0:00 /usr/sbin/sshd

So ssh is forking off a new sshd process that has privilege separation. Also if you look at lsof

sshd      16826 user txt       REG                8,3   546680    5247866 /usr/sbin/sshd

You can see it also

So when you upgrade the main server will restart and be upgraded but your current ssh session will stay online. You can even restart ssh server from a ssh session these days without losing your connection.