Compiling SSH binaries

This is if you’re sad and you like to do things yourself. Can be useful if you want to make mods to the source code too.

Make sure you do these steps on the same OS version that you’re planning to deploy the binary to.

  1. Download it
    wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.6p1.tar.gz
  2. Install the pre-reqs, whatever they were
  3. tar -xzf openssh-9.6p1.tar.gz
  4. cd into it, run ./configure
    • My one complained about zlib versions coz security
    • So tried this next command again…
  5. ./configure –prefix=/usr/local –sysconfdir=/etc/ssh –with-pam –with-privsep-path=/var/lib/sshd
  6. Will get something like this if it goes to plan:
  1. make -j$(nproc)
  2. sudo make install
  3. it might moan about privilege separation user sshd does not exist
    • if building this binary on a machine without ssh server installed, the user sshd wont exit.
  4. so not sure which bits of these are actually needed:
    • sudo mkdir -p /var/lib/sshd
    • sudo chown root:root /var/lib/sshd
    • sudo chmod 755 /var/lib/sshd
    • sudo useradd -r -d /var/empty/sshd -s /usr/sbin/nologin sshd
  5. Run your new server:
    • sudo /usr/local/sbin/sshd -p 2222 -D -e

To make changes to source and recompile (or whatevs):

  1. Make sure you’ve cd’d to your code, i.e., where your unzipped code is from step three.
  2. Make your changes to whatever file
  3. make -j$(nproc)
  4. sudo make install
  5. launch the server again.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *