0%

Upgrade openssh-server on Ubuntu

Backup

1
cp /etc/init.d/ssh /etc/init.d/ssh.old && cp -r /etc/ssh /etc/ssh.old

Download

Go to https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/, download the latest version package.

1
2
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.2p1.tar.gz
tar zxf openssh-8.2p1.tar.gz

Installation

1
2
3
4
5
6
7
8
9
sudo apt install libssl-dev
sudo apt install libpam-dev
sudo apt install libz-dev
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-privsep-path=/var/lib/sshd
make -j8
sudo make install

sudo chown 600 /etc/ssh/*key
chmod 600 ~/.ssh/authorized_keys

Problem

Job for ssh.service failed because a timeout was exceeded

1
apt-get install libsystemd-dev

add code in sshd.c before calling server_accept_loop

1
2
3
4
5
6
7
8
9
#include <systemd/sd-daemon.h>
...
/* Signal systemd that we are ready to accept connections */
sd_notify(0, "READY=1");

/* Accept a connection and return in a forked child */
server_accept_loop(&sock_in, &sock_out,
&newsock, config_s);
...

Makefile

1
LIBS=-lcrypto -ldl -lutil -lz  -lcrypt -lresolv -lsystemd

Reference