Adding SSH
SSH is a fundamental service to have on your system. Many would argue that it should be included in the default install, but I can foresee the posibility where some people wouldn't have a need/want for it on their system. So in the spirit of minimalism, I think it belongs in the addons.

We'll start by copying over the necessary binaries. Type the following:

cp /usr/bin/scp /usr/minibsd/usr/bin
cp /usr/bin/sftp /usr/minibsd/usr/bin
cp /usr/bin/ssh /usr/minibsd/usr/bin
cd /usr/minibsd/usr/bin
ln ssh slogin
cp /usr/bin/ssh-keygen /usr/minibsd/usr/bin
cp /usr/sbin/sshd /usr/minibsd/usr/sbin
cp /usr/libexec/sftp-server /usr/minibsd/usr/libexec

(Note: All commands are given in the "long" format strictly for the sake of clarity. You are of course welcome to copy the files over using whatever shorter method you are comfortable with.)

Next, use the script to make sure you have all the libraries the above binaries depend on. Type the following:

cd /root
/root/ > minibsd_ssh.libs

This will actually create a list of all the libraries that the system needs, including the ones already copied when you setup your core miniBSD system. It would be fine to just run against the newly created minibsd_ssh.libs file. However, if you prefer, you can take a look at the before and after differences between minibsd.libs (created when you setup your core miniBSD system) and minibsd_ssh.libs (created just now). Type the following:

diff /root/minibsd.libs /root/minibsd_ssh.libs

Whatever library file names you see are the newly required libraries that you need for SSH. Following my guide to the letter, this is the output I get from diff.

(Note: The following is just an output example. The following are not commands for you to type.)

> usr/lib/
> usr/lib/

I see that I need to copy over two new libraries. I do that by typing the following:

cp -p /usr/lib/ /usr/minibsd/usr/lib
cp -p /usr/lib/ /usr/minibsd/usr/lib

You will need to copy over each library to its respective location in your /usr/minibsd subdirectory. Then you'll have all the libraries you need for SSH - with one exception. According to the original miniBSD document, you also need to copy /usr/lib/*ypc* if you want to run sshd under 5.x. Type the following to copy over the additional libraries that are required by SSH:

cp -p /usr/lib/*ypc* /usr/minibsd/usr/lib

Now you need to copy and create the necessary configuration files. Type the following:

cp -R /etc/ssh /usr/minibsd/etc
ssh-keygen -t rsa1 -N "" -f /usr/minibsd/etc/ssh/ssh_host_key
ssh-keygen -t rsa -N "" -f /usr/minibsd/etc/ssh/ssh_host_rsa_key
ssh-keygen -t dsa -N "" -f /usr/minibsd/etc/ssh/ssh_host_dsa_key

If you want to permit root login, you'll need to edit the /usr/minibsd/etc/ssh/sshd_config file and search for the PermitRootLogin parameter, uncomment it, and change the value to yes.

PermitRootLogin yes

If you want the sshd daemon to start automatically when the system boots, you'll need to add the following line to your /usr/minibsd/etc/rc.conf file:


That's it. Rebuild your image and then give it a try.