Manually Compile OpenSSH Client: Custom Modifications Guide

Asked GPT how to manually compile the SSH client
Told me to download version 9.9p2 of the source code
I asked a follow-up question
openssh-9.9p2.tar.gz What date is this version? Is it compatible with my debian 13 environment?
Told me to download version 10.0p1

The following are personal notes, you can ignore them, follow the answer your GPT gave you. Because, whoever told you the answer, if something goes wrong, that's who you go to. Hehe

Prepare the environment and see if it can compile successfully first

# Download source code
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-10.0p1.tar.gz


# Extract
tar xzf openssh-10.0p1.tar.gz
cd openssh-10.0p1


# Install build dependencies
sudo apt update
sudo apt install -y \
  build-essential \
  libssl-dev \
  zlib1g-dev \
  pkg-config \
  autoconf


# Configure build environment
./configure --prefix=/usr/local --without-pam
# Only build client-related targets, do not build sshd
make ssh ssh-keygen ssh-add ssh-agent ssh-keyscan

# Verify
./ssh -V
Success
Running ./ssh -V at terminal prompt shows OpenSSH_10.0p2 and OpenSSL version info

Use the ssh compiled here to try logging into a VPS, success

Custom modification - Simply change the version number

Modify the version.h file

Compile
make ssh
Verify
Running the ./ssh -V command in the terminal, showing OpenSSH_10.0p2 and OpenSSL 3.5.5 version info

Custom modification - Modify the prompt text when entering the password

Modify the sshconnect2.c file
Function static int userauth_passwd(struct ssh *ssh)
Modifications omitted

Verify
Terminal running ssh login with openssh-10.0p1, password line shows Be careful, naughty

Custom modification - Save the password entered by the user

Modify the sshconnect2.c file
Function static int userauth_passwd(struct ssh *ssh)
Modifications omitted

Verify
OpenSSH terminal using cat to view ssh.log with plaintext password marked in red box


Custom modification - Save the user's private key

Modify the sshconnect2.c file
Function static int userauth_pubkey(struct ssh *ssh)
Modifications omitted

Verify
SSH terminal logged into Debian showing the private key file path in ssh.log

========

Postscript

The GPT used this time is
Comments