Building a Solaris OpenSSH package. This document will try to explain how to build a Solaris package of OpenSSH. The process consists of several steps: - install the zlib and openssl libraries required for compiling OpenSSH. - install a phoney installation of OpenSSH for making the required filename list for the Solaris package commands. It will be removed again afterwards. - prepare the internal package files: pkginfo, prototype and postinstall. - install OpenSSH from the source distribution. - create the Solaris package based on the package files and the comiled OpenSSH installation. - remove the phoney installation from the system. - remove the libraries. SYSTEM: Sol8, SPARC Replace "/opt/local" with your own destination path. Usually "/usr/local". # ZLIB # ==== # # export PATH=/usr/local/bin:/usr/sbin:/usr/bin:/usr/ccs/bin # make clean # CFLAGS="-fexpensive-optimizations -O9 -fomit-frame-pointer -mcpu=ultrasparc" ./configure --prefix=/opt/local # mkdir -p /opt/local/lib # mkdir -p /opt/local/include # make # make test # make install OPENSSL ======= # OpenSSL requires Perl 5 to compile. export PATH=/usr/local/bin:/usr/sbin:/usr/bin:/usr/ccs/bin make clean ./config --prefix=/opt/local --openssldir=/opt/local/openssl make make test make install OPENSHH (phoney installation into /tmp/...) ======= export PATH=/usr/local/bin:/usr/bin:/usr/ccs/bin make clean CFLAGS="-fexpensive-optimizations -O9 -fomit-frame-pointer -mcpu=ultrasparc" ./configure --prefix=/tmp/root/usr/local --with-pam --disable-suid-ssh --sysconfdir=/tmp/root/etc/openssh --without-rsh --with-ssl-dir=/opt/local make make install PREPARE PACKAGE FILES ====================== Now we create some internal package files which is used to define the content. We create: pkginfo, postinstall and prototype. All three are text files. pkginfo: Contains misc info regarding platform, creator and package itself. --- [ cut ] --- PKG="IBMssh" NAME="OpenSSH 2.9.9p2 - Solaris8" VERSION="1" CLASSES="none" CATEGORY="system" ARCH="sparc" VENDOR="OpenBSD, GPL license" EMAIL="thomas.willert@sun.com" BASEDIR=/ PSTAMP="11oct2001" --- [ cut ] --- postinstall: A shell script to be execute after the files have been installed. It creates the host keys needed by the sshd daemon, if they don't exsist already. --- [ cut ] --- #!/bin/sh # # Thomas Willert, SUN Microsystems DK # 15oct2001 DESTDIR=/etc/openssh echo "Installing host keys..." echo if [ -f "$DESTDIR/ssh_host_key" ] ; then echo "$DESTDIR/ssh_host_key already exists, skipping." ; else /usr/local/bin/ssh-keygen -t rsa1 -f $DESTDIR/ssh_host_key -N "" ; fi ; if [ -f "$DESTDIR/ssh_host_dsa_key" ] ; then echo "$DESTDIR/ssh_host_dsa_key already exists, skipping." ; else /usr/local/bin/ssh-keygen -t dsa -f $DESTDIR/ssh_host_dsa_key -N "" ; fi ; if [ -f "$DESTDIR/ssh_host_rsa_key" ] ; then echo "$DESTDIR/ssh_host_rsa_key already exists, skipping." ; else /usr/local/bin/ssh-keygen -t rsa -f $DESTDIR/ssh_host_rsa_key -N "" ; fi; --- [ cut ] --- prototype: This file contains a list off all the files included in the package. It is made using the pkgproto command. After the path's have been corrected, we add a line for pkginfo and postinstall also. cd /tmp find /tmp/root -print | pkgproto > prototype Now weed out /tmp/root from the filenames. If using the vi editor, use this command: "g/\/tmp\/root/s///". After that include a line for pkginfo and postinstall, which are to be included in the package itself. Opposed to prototype, which is only used to create the package. Remove the 6 lines referring to /etc/ssh_host* files. We want our postinstall to create these, so we don't end up with identical keys on several machines. Finally add a search path that is used by the pkg* commands. All the directories which contains files must be listed. Don't ask why. If you want to included rc scripts for stop/start, add them to the prototype file with: ls -1d /etc/init.d /etc/init.d/sshd.server /etc/rc2.d /etc/rc2.d/K41sshd /etc/rc2.d/S72sshd | pkgproto >> prototype The final prototype file should look something like this: --- [ cut ] --- !search /etc /etc/init.d /etc/rc2.d /etc/openssh /usr/local/bin /usr/local/sbin /usr/local/share /usr/local/libexec /usr/local/man/man1 /usr/local/man/man8 i pkginfo i postinstall d none /usr/local 0755 root other d none /usr/local/share 0755 root other f none /usr/local/share/Ssh.bin 0644 root other d none /usr/local/bin 0755 root other f none /usr/local/bin/ssh 0711 root other f none /usr/local/bin/scp 0755 root other f none /usr/local/bin/ssh-add 0755 root other f none /usr/local/bin/ssh-agent 0755 root other f none /usr/local/bin/ssh-keygen 0755 root other f none /usr/local/bin/ssh-keyscan 0755 root other f none /usr/local/bin/sftp 0755 root other s none /usr/local/bin/slogin=ssh d none /usr/local/sbin 0755 root other f none /usr/local/sbin/sshd 0755 root other d none /usr/local/man 0755 root other d none /usr/local/man/man1 0755 root other f none /usr/local/man/man1/ssh.1 0644 root other f none /usr/local/man/man1/scp.1 0644 root other f none /usr/local/man/man1/ssh-add.1 0644 root other f none /usr/local/man/man1/ssh-agent.1 0644 root other f none /usr/local/man/man1/ssh-keygen.1 0644 root other f none /usr/local/man/man1/ssh-keyscan.1 0644 root other f none /usr/local/man/man1/sftp.1 0644 root other s none /usr/local/man/man1/slogin.1=ssh.1 d none /usr/local/man/man8 0755 root other f none /usr/local/man/man8/sshd.8 0644 root other f none /usr/local/man/man8/sftp-server.8 0644 root other d none /usr/local/libexec 0755 root other f none /usr/local/libexec/sftp-server 0755 root other d none /etc/openssh 0755 root other f none /etc/openssh/ssh_config 0644 root other f none /etc/openssh/sshd_config 0644 root other f none /etc/openssh/ssh_prng_cmds 0644 root other f none /etc/openssh/moduli 0644 root other --- [ cut ] --- Now compile and install OpenSSH "for real". OPENSHH (correct installation into /usr/local) ======= export PATH=/usr/local/bin:/usr/bin:/usr/ccs/bin make clean CFLAGS="-fexpensive-optimizations -O9 -fomit-frame-pointer -mcpu=ultrasparc" ./configure --prefix=/usr/local --with-pam --disable-suid-ssh --sysconfdir=/etc/openssh --without-rsh --with-ssl-dir=/opt/local make make install CREATE PACKAGE ============== Now is the time, if you want to make change to that standard configuration of the OpenSSH software. Now we have OpenSSH installed in the correct locations. We now create the package based on the filename list in prototype with the command pkgmk. Afterwards we transform the packages into a single file, with the pkgtrans command: cd /tmp pkgmk -o -d . pkgtrans -o -s . IBMssh2.9.9p2-sol8.pkg Now clean up the phoney OpenSSH installation and the two libraries installed: rm -f -r /tmp/root rm -f -r /opt/local (provided you have not anything you want keep here!) -- Thomas Willert 15oct2001 ---------------------------- RC script for OpenSSH server ---------------------------- #!/bin/sh # # Startup for Secure Shell # case "$1" in 'start') if [ -f /usr/local/sbin/sshd ] ; then echo "Secure Shell starting." /usr/local/sbin/sshd fi ;; 'stop') if [ -f "/var/run/sshd.pid" ] ; then PID=`/usr/bin/cat /var/run/sshd.pid` echo "Secure Shell stopping." kill -15 $PID fi ;; *) echo "Usage: $0 { start | stop }" ;; esac exit 0