Last active
September 14, 2020 05:46
-
-
Save mklooss/052fd450f1250fb8aa6f41fe4c7aa07f to your computer and use it in GitHub Desktop.
chroot ssh builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Chroot Builder | |
cp -RLv /etc/ca-certificates /home/testing/etc/ | |
cp -RLv /etc/ssl /home/testing/etc/ | |
cp -Lv -vf /etc/{passwd,group,hostname,resolv.conf} /home/testing/etc/ | |
LBIN="bash ls cp mc mv pwd dircolors mkdir rm chmod id patch diff awk rsync whoami ssh git git-receive-pack git-shell git-upload-archive git-upload-pack openssl hostname wget curl nice gzip gunzip xz unxz zip unzip lsof mysql mysqldump sed tar less ping mtr nslookup dig jpegoptim jpegtran guetzli cwebp optipng pngquant gif2webp zopflipng" | |
for f in $LBIN; do | |
WHICH=$(which $f) | |
if [ ! -z "$WHICH" ]; then | |
cp -Lv $WHICH /home/testing/bin/ | |
fi | |
done | |
mkdir -p /home/testing/lib/ | |
find /lib -maxdepth 1 -iname "ld-linux-*.so*" -exec cp -Lv "{}" /home/testing/lib/ \; | |
for ld in $(find /home/testing/bin/ -type f -exec ldd "{}" \; | awk '{print $3}' | grep -v jpegtran | uniq | sed -r '/^\s*$/d'); do | |
cp -Lv "$ld" /home/testing/lib/ | |
done | |
# fix git ssh | |
find /usr/lib -maxdepth 2 -iname "libcurl-gnutls*.so*" -exec cp -Lv "{}" /home/testing/lib/ \; | |
find /usr/lib -maxdepth 2 -iname "libcurl*.so*" -exec cp -Lv "{}" /home/testing/lib/ \; | |
find /usr/lib -maxdepth 2 -iname "libpthread*.so*" -exec cp -Lv "{}" /home/testing/lib/ \; | |
find /usr/lib -maxdepth 2 -iname "libnss*.so*" -exec cp -Lv "{}" /home/testing/lib/ \; | |
# git workaround | |
mkdir -p /home/testing/usr/share/ | |
cp -RvL /usr/share/git-core /home/testing/usr/share/ | |
cp -RvL /usr/lib/git-core /home/testing/usr/lib/ | |
for ld in $(find /usr/lib/git-core -type f -exec ldd "{}" \; | awk '{print $3}' | uniq | sed -r '/^\s*$/d'); do | |
cp -Lv "$ld" /home/testing/lib/ | |
done | |
for ld in $(find /home/testing/lib/ -type f -exec ldd "{}" \; | awk '{print $3}' | uniq | sed -r '/^\s*$/d'); do | |
cp -Lv "$ld" /home/testing/lib/ | |
done | |
# Workaround for jpegtran - mozjpeg | |
if [ -d "/home/testing/usr/lib/x86_64-linux-gnu" ]; then | |
mkdir -p /home/testing/usr/lib/x86_64-linux-gnu | |
cp -RLv /usr/lib/x86_64-linux-gnu/mozjpeg /home/testing/usr/lib/mozjpeg | |
fi | |
chown root.root /home/testing/ | |
chown testing.testing /home/testing/home/testing/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment