Download :
- openssh-9.0p1.tar.gz from https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.0p1.tar.gz
- openssl-3.0.7.tar.gz from https://www.openssl.org/source/openssl-3.0.7.tar.gz
 - zlib 1.2.13 from https://zlib.net/zlib-1.2.13.tar.gz
Note: Very important to compile in /tmp and not in a home directory or it may cause NFS lookups when executing ssh

setenv CC gcc
export CC=gcc

====================
Solaris:
====================
module add perl/5.10.1
cd /tmp
rm -rf openssh-7.9p1 
rm -rf openssl-1.1.1c
gzip -df openssh-7.9p1.tar.gz 
gzip -df openssl-1.1.1c.tar.gz 
tar xf openssl-1.1.1c.tar 
tar xf openssh-7.9p1.tar

Solaris/sparc: module add gcc/3.4.6 && module add zlib/1.2.3  && module add gmake
cd /tmp/openssl-1.1.1c
cp ~/moshell/commonjars/src/openssh/patches/0001-Moshell-SSL-mods-1.1.1c.patch .
Solaris: gpatch -p1 -i 0001-Moshell-SSL-mods-1.1.1c.patch
Solaris:       x86:    ./Configure solaris-x86-gcc no-shared   
               sparc:  ./Configure solaris-sparcv9-gcc no-shared
               Then edit the Makefile and replace the following lines :
               in the line starting with CNF_CFLAGS= , replace -pthread with -pthreads
               in the line starting with CNF_EX_LIBS=, replace -pthread with -pthreads -lrt
               Then run : make

cd /tmp/openssh-7.9p1
cp ~/moshell/commonjars/src/openssh/patches/0001-Moshell-SSH-mods-7.9p1*.patch .
Solaris: gpatch -p1 -i 0001-Moshell-SSH-mods-7.9p1.patch
Solaris/sparc: ./configure --with-ssl-dir=../openssl-1.1.1c --without-zlib-version-check && make
Solaris/x86:   ./configure --with-ssl-dir=../openssl-1.1.1c && make 

Keep the following files and store them in the following locations, with the correct extension (.solaris, .sol86, .exe)
export os=lin64 (or exe, linux, solaris sol86 exe  - choose appropriate one)
strip /tmp/openssh-7.9p1/ssh            && cp /tmp/openssh-7.9p1/ssh           ~/moshell/commonjars/ssh.$os
strip /tmp/openssh-7.9p1/sftp           && cp /tmp/openssh-7.9p1/sftp          ~/moshell/commonjars/sftp.$os
strip /tmp/openssh-7.9p1/sshd           && cp /tmp/openssh-7.9p1/sshd          ~/moshell/commonjars/sshd.$os
strip /tmp/openssh-7.9p1/sftp-server    && cp /tmp/openssh-7.9p1/sftp-server   ~/moshell/commonjars/sftp-server.$os
strip /tmp/openssh-7.9p1/scp            && cp /tmp/openssh-7.9p1/scp           ~/moshell/commonjars/scp.$os
strip /tmp/openssl-1.1.1c/apps/openssl  && cp /tmp/openssl-1.1.1c/apps/openssl ~/moshell/commonjars/openssl.$os

====================
Linux/Cygwin:
====================
Linux only: Compile on seliiuts02930 or ottlsvr18 (libc 2.11.3) (or seliiuts02929 or sekilx484.wrbs.rnd.ki.sw.ericsson.se or sekilx1260.wrbs.rnd.ki.sw.ericsson.se)

Cygwin only: Make sure that the following dependencies are installed:
	gcc-core
	patch
	make
	libncurses-devel

setenv CC gcc
export CC=gcc
module add perl/5.10.1
module add gcc/10.2.0
module add make/4.3

cd /tmp
unzip ~/moshell/commonjars/src/openssh/patches.zip -d ~/moshell/commonjars/src/openssh/
rm -rf zlib-1.2.13 && tar xf zlib-1.2.13.tar.gz
cd /tmp/zlib-1.2.13
#on cygwin32 (not needed for 64), run: cp ~/moshell/commonjars/src/openssh/patches/1.2.13-cygwin-no-widechar.patch .  && patch -p1 -i 1.2.13-cygwin-no-widechar.patch
env CFLAGS="-g -O2 -fPIC" LDSHARED="gcc " ./configure && make 

cd /tmp
rm -rf openssh-9.0p1 && tar xf openssh-9.0p1.tar.gz
rm -rf openssl-3.0.7 && tar xf openssl-3.0.7.tar.gz

cd /tmp/openssl-3.0.7
cp ~/moshell/commonjars/src/openssh/patches/0001-Moshell-SSL-mods-3.0.5.patch .
cp ~/moshell/commonjars/src/openssh/patches/0001-Restore-SHA1-security-strength.patch .
cp ~/moshell/commonjars/src/openssh/patches/0001-Allow-client-unsafe-renegotiation.patch .
patch -p1 -i 0001-Moshell-SSL-mods-3.0.5.patch
patch -p1 -i 0001-Restore-SHA1-security-strength.patch
patch -p1 -i 0001-Allow-client-unsafe-renegotiation.patch
Linux:  ./config -fPIC no-shared no-threads && make depend && make
Cygwin: ./config no-shared no-threads && make depend && make

cd /tmp/openssh-9.0p1
cp ~/moshell/commonjars/src/openssh/patches/0001-Moshell-SSH-mods-9.0p1.patch .
patch -p1 -i 0001-Moshell-SSH-mods-9.0p1.patch
Linux: env CFLAGS="-std=gnu99 -g -O2 -fPIC" LDSHARED="gcc " ./configure --with-ssl-dir=../openssl-3.0.7 --with-zlib=../zlib-1.2.13 && make
Cygwin: ./configure --with-ssl-dir=../openssl-3.0.7 --with-zlib=../zlib-1.2.13 && make

Keep the following files and store them in the following locations, with the correct extension (.linux, .lin64)
os=exe lin64 linux exe (choose appropriate one)
echo $os
strip /tmp/openssh-9.0p1/ssh            && cp /tmp/openssh-9.0p1/ssh           ~/moshell/commonjars/ssh.$os
strip /tmp/openssh-9.0p1/sftp           && cp /tmp/openssh-9.0p1/sftp          ~/moshell/commonjars/sftp.$os
strip /tmp/openssh-9.0p1/sshd           && cp /tmp/openssh-9.0p1/sshd          ~/moshell/commonjars/sshd.$os
strip /tmp/openssh-9.0p1/sftp-server    && cp /tmp/openssh-9.0p1/sftp-server   ~/moshell/commonjars/sftp-server.$os
strip /tmp/openssh-9.0p1/scp            && cp /tmp/openssh-9.0p1/scp           ~/moshell/commonjars/scp.$os
strip /tmp/openssl-3.0.7/apps/openssl  && cp /tmp/openssl-3.0.7/apps/openssl ~/moshell/commonjars/openssl.$os

update mos2emInfo["ssh_version"] in moshell/prog.awk

###################
esekilxxen1250 [17:51] [/home/eanzmagn] -> uname -a
Linux esekilxxen1250 2.6.16.60-0.103.1-xen #1 SMP Thu May 16 19:52:34 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
esekilxxen1250 [18:29] [/home/eanzmagn] -> ldd --version
ldd (GNU libc) 2.4
uesekilxv7065 [18:30] [/home/eanzmagn] -> uname -a
Linux esekilxv7065 3.0.101-108.108-default #1 SMP Mon Nov 11 14:07:08 UTC 2019 (6f4f848) x86_64 x86_64 x86_64 GNU/Linux
esekilxv7065 [18:30] [/home/eanzmagn] -> ldd --version
ldd (GNU libc) 2.11.3
seliius01071 [18:31] [/home/eanzmagn] -> uname -a
Linux seliius01071 2.6.32-504.el6.x86_64 #1 SMP Tue Sep 16 01:56:35 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
seliius01071 [18:32] [/home/eanzmagn] -> ldd --version
ldd (GNU libc) 2.12
seliius01071 [18:32] [/home/eanzmagn] -> 


#############################
How to make the patch files:
#############################
mkdir dummy
cd dummy
module add git
git init
-------------------
tar -xf openssl-1.0.2k.tar.gz
cd openssl-1.0.2k
cp -R ../dummy/.git .
git add -A :/
git commit -m 'Base'
cp ~/moshell/commonjars/src/openssh/sshmods/ssl/* .
cp ~/moshell/commonjars/src/openssh/sshmods/apps/* apps
git status
git add -A :/
git commit -m 'Moshell SSL mods 1.0.2k'
git format-patch HEAD^
---------------------
tar -xf openssh-7.4p1.tar.gz
cd openssh-7.4p1
cp -R ../dummy/.git .
git add -A :/
git commit -m 'Base'
cp ~/moshell/commonjars/src/openssh/sshmods/ssh/* .
git status
git add -A :/
git commit -m 'Moshell SSH mods 7.4p1'
git format-patch HEAD^

#############################

#Not needed anymore on solaris/x86 (or because already done on iov86?)
#First, patch the gcc compiler by downloading the file www.openssl.org/~appro/values.c and store under /tmp/openssl-1.0.0a
#Then run: ksh -f values.c gcc
