update at 2026-03-15 14:54:51

This commit is contained in:
douboer@gmail.com
2026-03-15 14:54:51 +08:00
parent c02b23bad2
commit d375f7174f
26 changed files with 1284 additions and 15 deletions

View File

@@ -0,0 +1,38 @@
#!/bin/sh
set -eu
# 把 usbnet 共用的 authorized_keys 同步到几处常见 root SSH 目录,
# 避免不同 sshd/dropbear 读取路径不一致。
TS="$(date +%Y%m%d-%H%M%S 2>/dev/null || echo now)"
OUT_DIR="/mnt/us/ssh-debug/${TS}"
LOG_FILE="${OUT_DIR}/fix-all-keys.log"
SOURCE_KEYS="/mnt/us/usbnet/etc/authorized_keys"
mkdir -p "${OUT_DIR}"
exec >"${LOG_FILE}" 2>&1
ROOT_HOME="$(awk -F: '/^root:/{print $6}' /etc/passwd 2>/dev/null || true)"
[ -n "${ROOT_HOME}" ] || ROOT_HOME="/tmp/root"
echo "Root home: ${ROOT_HOME}"
echo "Source keys: ${SOURCE_KEYS}"
for target_dir in "${ROOT_HOME}/.ssh" /root/.ssh /var/local/root/.ssh /mnt/us/usbnet/etc/dot.ssh; do
echo "--- target: ${target_dir} ---"
mkdir -p "${target_dir}"
if [ -f "${target_dir}/authorized_keys" ]; then
cp "${target_dir}/authorized_keys" "${target_dir}/authorized_keys.bak.${TS}" || true
fi
cp "${SOURCE_KEYS}" "${target_dir}/authorized_keys"
chmod 700 "${target_dir}" 2>/dev/null || true
chmod 600 "${target_dir}/authorized_keys" 2>/dev/null || true
ls -ld "${target_dir}" "${target_dir}/authorized_keys" 2>/dev/null || true
done
killall -HUP sshd 2>/dev/null || true
echo
echo "=== DONE ==="
echo "${OUT_DIR}"