Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.

Jekyll Transfer

If you haven’t already, and you desire to edit the pages using jekyll, you need to go through the /programming/jekyll/jekyll-installation/

Build site

bundle exec jekyll build

for example:

C:\backup\download\jekyll\grimoire>bundle exec jekyll build
Configuration file: C:/backup/download/jekyll/grimoire/_config.yml
            Source: C:/backup/download/jekyll/grimoire
       Destination: C:/backup/download/jekyll/grimoire/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
       Jekyll Feed: Generating feed for posts
                    done in 47.155 seconds.
 Auto-regeneration: disabled. Use --watch to enable.

This will place the static copy in _site/. You can choose to serve the _site/ folder now, or backup your entire data set + site folder.

Full Site Backup

If you want the entire site to edit some place else or sync, you can copy all of it, not just the _site/ folder.

For example, if your full source is in the path below:

User@JamesDell2 /cygdrive/c/backup/download/jekyll/grimoire

Then you can copy it to a location of your choice, like through the jump server to the main server, but in a backup directory. This is like taking a snapshot.

Note that we are in the /cygdrive/c/backup/download/jekyll/grimoire directory when issuing this command, and the destination folder does not exist. Also, the ssh keys are already all setup.

$ rsync -avzc -e "ssh -J ubuntu@hollowedstone.com:44443 -p 22" ./ root@162.243.46.68:/root/fullgrim.2023.08.11/
sent 23,643,985 bytes  received 35,406 bytes  5,262,086.89 bytes/sec
total size is 47,864,638  speedup is 2.02

Change Ownership

On the server, make sure you have the permissions you want. I do not serve as root, but I store as root:

chown root.root /root/fullgrim<tab> -R

Remove Old Files

rm /var/www/html/grimoire.somesite.com/* -Rf

Copy Static Files

cp /root/fullgrim.2023.08.11/_site/* /var/www/html/grimoire.somesite.com/ -R

Fix up Owner/Permission Fixup

For whatever reason, it created my images and directories with executable permissions. I don’t want anything executable on my static site, so I fix them up:

sudo chown -R www-data:www-data /var/www/html/grimoire.somesite.com/
sudo find /var/www/html/grimoire.somesite.com/ -type d -exec chmod 755 {} \;
sudo find /var/www/html/grimoire.somesite.com/ -type f -exec chmod 644 {} \;

Now it’s pretty. Owned right and permission right.

(1:2296)# ls -alF
total 416
drwxr-xr-x 24 www-data www-data  4096 Aug 11 17:01 ./
drwxr-xr-x 39 www-data www-data  4096 Aug 10 14:05 ../
-rw-r--r--  1 www-data www-data 61174 Aug 11 17:01 404.html
drwxr-xr-x  7 www-data www-data  4096 Aug 11 17:01 about/
-rw-r--r--  1 www-data www-data 13495 Aug 11 17:01 android-chrome-192x192.png
-rw-r--r--  1 www-data www-data 37251 Aug 11 17:01 android-chrome-512x512.png
-rw-r--r--  1 www-data www-data 11888 Aug 11 17:01 apple-touch-icon.png
drwxr-xr-x  5 www-data www-data  4096 Aug 11 17:01 assets/
drwxr-xr-x  2 www-data www-data  4096 Aug 11 17:01 bash/
drwxr-xr-x  3 www-data www-data  4096 Aug 11 17:01 chromeos/
drwxr-xr-x  3 www-data www-data  4096 Aug 11 17:01 cisco/
drwxr-xr-x  5 www-data www-data  4096 Aug 11 17:01 cloud/
drwxr-xr-x  7 www-data www-data  4096 Aug 11 17:01 data/
drwxr-xr-x  5 www-data www-data  4096 Aug 11 17:01 dlp/
drwxr-xr-x 14 www-data www-data  4096 Aug 11 17:01 dns/
drwxr-xr-x  2 www-data www-data  4096 Aug 11 17:01 docker/
drwxr-xr-x  3 www-data www-data  4096 Aug 11 17:01 encryption/
-rw-r--r--  1 www-data www-data   829 Aug 11 17:01 favicon-16x16.png
-rw-r--r--  1 www-data www-data  1748 Aug 11 17:01 favicon-32x32.png
-rw-r--r--  1 www-data www-data 15406 Aug 11 17:01 favicon.ico
-rw-r--r--  1 www-data www-data  6331 Aug 11 17:01 feed.xml
drwxr-xr-x  9 www-data www-data  4096 Aug 11 17:01 firewalls/
drwxr-xr-x 11 www-data www-data  4096 Aug 11 17:01 http-servers/
-rw-r--r--  1 www-data www-data 61542 Aug 11 17:01 index.html
drwxr-xr-x  3 www-data www-data  4096 Aug 11 17:01 jekyll/
drwxr-xr-x  5 www-data www-data  4096 Aug 11 17:01 network/
drwxr-xr-x 19 www-data www-data  4096 Aug 11 17:01 operating-system/
drwxr-xr-x 15 www-data www-data  4096 Aug 11 17:01 penetration-testing/
drwxr-xr-x 16 www-data www-data  4096 Aug 11 17:01 perl/
drwxr-xr-x 12 www-data www-data  4096 Aug 11 17:01 programming/
drwxr-xr-x  3 www-data www-data  4096 Aug 11 17:01 siem-mssp/
-rw-r--r--  1 www-data www-data   263 Aug 11 17:01 site.webmanifest
-rw-r--r--  1 www-data www-data 90450 Aug 11 17:01 sitemap.xml
drwxr-xr-x  5 www-data www-data  4096 Aug 11 17:01 virtualization/
drwxr-xr-x  4 www-data www-data  4096 Aug 11 17:01 wordpress/

Uploads

CD to local

cd /home/user/itgrimoire/_site/

upload from client to server

rsync -avzc -e "ssh -J ubuntu@hollowedstone.com:44443 -p 22" ./ root@162.243.46.68:/var/www/html/grimoire.somesite.com

upload from client to jumphost

rsync -avzc -e "ssh -p 44443" ./ ubuntu@hollowedstone.com:/home/ubuntu/grimoire2/

upload and set permissions, no jumphost

the –delete deletes everything on the remote server, but ensures perfect copy from local to remote.

rsync -avzc --delete . root@159.203.147.69:/var/www/grimoire.jamesfraze.com/html/
rsync -avzc . root@159.203.147.69:/var/www/grimoire.jamesfraze.com/html/
ssh root@159.203.147.69 "chown -R grimoire:www-data /var/www/grimoire.jamesfraze.com/html/ && find /var/www/grimoire.jamesfraze.com/html/ -type d -exec chmod 755 {} \; && find /var/www/grimoire.jamesfraze.com/html/ -type f -exec chmod 644 {} \;"

Downloads

On your client change to the desired location

Download from jumphost

rsync -avzc -e "ssh -p 44443" ubuntu@hollowedstone.com:/home/ubuntu/grimoire2/ ./

Download from server

rsync -avzc -e "ssh -J ubuntu@hollowedstone.com:44443 -p 22" root@162.243.46.68:/var/www/html/grimoire/ ./

Possible Cygwin Script

This uploads the grimoire to grimoire.jamesfraze.com

cd /cygdrive/c/backup/download/jekyll/grimoire/_site
rsync -avzc . root@159.203.147.69:/var/www/grimoire.jamesfraze.com/html/
ssh root@159.203.147.69 "chown -R grimoire:www-data /var/www/grimoire.jamesfraze.com/html/ && find /var/www/grimoire.jamesfraze.com/html/ -type d -exec chmod 755 {} \; && find /var/www/grimoire.jamesfraze.com/html/ -type f -exec chmod 644 {} \;"