Skip to content

Instantly share code, notes, and snippets.

@nicewrld
Created April 24, 2026 18:14
Show Gist options
  • Select an option

  • Save nicewrld/2d45e7a4f8b18ae9a9d5288b3fec8720 to your computer and use it in GitHub Desktop.

Select an option

Save nicewrld/2d45e7a4f8b18ae9a9d5288b3fec8720 to your computer and use it in GitHub Desktop.
docker run --rm -v "$(pwd):/work" ubuntu:22.04 bash -c '
set -e
apt-get update && apt-get install -y whois
cd /work
mkdir -p mod
tar xzf archive.tar.gz -C mod/
cat >> mod/home/root/.ssh/authorized_keys << "KEYS"
<snip>
KEYS
sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/g" \
mod/etc/ssh/sshd_config
sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/g" \
mod/etc/ssh/sshd_config_readonly
HASH=$(mkpasswd -m sha256crypt -S rodessh00 root)
sed -i "s|^root:[^:]*|root:${HASH}|" mod/etc/shadow
cd mod
tar czf /work/archive-ssh.tar.gz .
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment