#!/bin/bash
+# I, Ian Kelling, follow the GNU license recommendations at
+# https://www.gnu.org/licenses/license-recommendations.en.html. They
+# recommend that small programs, < 300 lines, be licensed under the
+# Apache License 2.0. This file contains or is part of one or more small
+# programs. If a small program grows beyond 300 lines, I plan to switch
+# its license to GPL.
+
+# Copyright 2024 Ian Kelling
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# meant to be copy/pasted
destroy
rescue
+
sudo -i
mkdir -p /root/.ssh
chmod 700 /root/.ssh
cat >/root/.ssh/authorized_keys <<'EOF'
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDX42yru/h6r6UDRy/VwVZjcYEmNLG5/SUjv7xwu43OaW0wL+uHYg2rkfn4Ygh5o1I5pgBh2SWg8TeWuVGhgL1SCuBzzeai/+58Sny065Qak+D2WjVOuRonRelh+CBA5EpNZPuiWQkoWdf9NACTBCbS2Zu7r8OOgRqu/ruaDNePlG5+U0Wlpy3oBnpbzQiuSA3AKMW30fsCJtOBjz5qQaiPbYEKJy3AOvtbq10wliKx9TpsTzrq8dKWs7PLhZnzqVCsaq6D95IzjqXcSpx4Cga5bn+YEuAnJQ53PGA5eO+hpz6HDmawTbJlaV/Dufb9bJ/ZZy1DXzs07yWRtTEY54/X ian@iankelling.org
EOF
+
apt update
-apt -y install openssh-server
+if [[ -e /usr/sbin/sshd ]]; then
+ systemctl restart ssh
+else
+ apt -y install openssh-server
+fi
##### in another terminal ######
-host=je
-scp /b/ds/bitfolk* root@$host.b8.nz:
-ssh root@$host ./bitfolk-rescue-install $host
+h=bk
+
+scp -pr --chown=root:root /p/c/machine_specific/$h/filesystem/etc/ssh/ root@$h.b8.nz:/etc/ssh
+
+scp /b/ds/bitfolk* root@$h.b8.nz:
+
+# initially saved via:
+# mkc /p/c/machine_specific/$h/filesystem/etc/ssh/
+# rsync -a root@$h:/etc/ssh/ssh_host* .
+ssh root@$h ./bitfolk-rescue-install $h
### back to the 1st terminal
-poweroff
boot
-# press ctrl ]
+# after boot, press ctrl ]
exit
-jepush
-# todo: lets copy the host keys around so we dont have to do this.
-khfix je
-sl root@je /a/bin/ds/distro-begin
+h=bk
+${h}push
+sl root@$h /a/bin/ds/distro-begin
-# todo, fix it so i can ssh to
-sl je /a/bin/ds/distro-begin
-sl je /a/bin/ds/distro-end
+sl $h /a/bin/ds/dall