Download :
 - openssh7.9p1.tar.gz from http://ftp.uio.no/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.tar.gz 
 - openssh8.3p1.tar.gz from http://ftp.uio.no/pub/OpenBSD/OpenSSH/portable/openssh-8.3p1.tar.gz
 - openssl1.1.1c.tar.gz from https://www.openssl.org/source/old/1.1.1/openssl-1.1.1c.tar.gz
 - openssl1.1.1g.tar.gz from https://www.openssl.org/source/old/1.1.1/openssl-1.1.1g.tar.gz
 - zlib 1.2.11 from https://zlib.net/zlib-1.2.11.tar.gz
Note: Very important to compile in /tmp and not in a home directory or it may cause NFS lookups when executing ssh

Compilation machines: 
 - for solaris/sparc, works on esekits1088.seki.rnd.ericsson.se with module add gcc/3.4.6 && module add zlib/1.2.3  && module add make/3.82 (or gmake), 
 - for linux 32, works on esekilxxen1231.rnd.ericsson.se (32-bit machine with old linux version 2.6.16 and old libc 2.4) with module add gcc/3.4.6 -> use old glibc to avoid problems when running on a old linux machine 
 - for linux 64, works on esekilxxen1250.rnd.ericsson.se (64-bit machine with old linux version 2.6.16 and old libc 2.4) 
 - for solaris/x86, works on eswki51komp.rnd.ki.sw.ericsson.se


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)
os= 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: 
module add perl/5.10.1
rm -rf zlib-1.2.11 && tar xf zlib-1.2.11.tar.gz
cd /tmp/zlib-1.2.11
chmod 755 configure
env CFLAGS="-g -O2 -fPIC" LDSHARED="gcc " ./configure && make

Linux/Cygwin:
cd /tmp
rm -rf openssh-8.3p1 && tar xf openssh-8.3p1.tar.gz
rm -rf openssl-1.1.1g && tar xf openssl-1.1.1g.tar.gz

unzip ~/moshell/commonjars/src/openssh/patches.zip -d ~/moshell/commonjars/src/openssh/
cd /tmp/openssl-1.1.1g
cp ~/moshell/commonjars/src/openssh/patches/0001-Moshell-SSL-mods-1.1.1f.patch .
patch -p1 -i 0001-Moshell-SSL-mods-1.1.1f.patch
Linux:  ./config -fPIC no-shared no-threads && make depend && make
Cygwin: ./config no-shared no-threads && make depend && make

cd /tmp/openssh-8.3p1
cp ~/moshell/commonjars/src/openssh/patches/0001-Moshell-SSH-mods-8.3p1.patch .
patch -p1 -i 0001-Moshell-SSH-mods-8.3p1.patch
Linux: ./configure --with-ssl-dir=../openssl-1.1.1g --with-zlib=../zlib-1.2.11 && make    
Cygwin: ./configure --with-ssl-dir=../openssl-1.1.1g && make

Keep the following files and store them in the following locations, with the correct extension (.linux, .lin64)
os= lin64 linux exe (choose appropriate one)
strip /tmp/openssh-8.3p1/ssh            && cp /tmp/openssh-8.3p1/ssh           ~/moshell/commonjars/ssh.$os
strip /tmp/openssh-8.3p1/sftp           && cp /tmp/openssh-8.3p1/sftp          ~/moshell/commonjars/sftp.$os
strip /tmp/openssh-8.3p1/sshd           && cp /tmp/openssh-8.3p1/sshd          ~/moshell/commonjars/sshd.$os
strip /tmp/openssh-8.3p1/sftp-server    && cp /tmp/openssh-8.3p1/sftp-server   ~/moshell/commonjars/sftp-server.$os
strip /tmp/openssh-8.3p1/scp            && cp /tmp/openssh-8.3p1/scp           ~/moshell/commonjars/scp.$os
strip /tmp/openssl-1.1.1g/apps/openssl  && cp /tmp/openssl-1.1.1g/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
