Setting up my writing environment
Setting up my writing environment#
A major project that I took on over the summer was fixing my rather flat home network to include separate VLANs for me, the family, the various smart devices around the house, the DMZ, and my server network. During that project I thought, “how can I make this harder on myself?”
I am not a particularly smart individual, so I like to keep things simple, so I assign a class C subnet to each VLAN, and I use numbers that I can easily remember:
| Name | VLAN | Class C | Mnemonic |
|---|---|---|---|
| DMZ | 38 | 192.168.38.0/24 | the 38th parallel |
| Server | 42 | 192.168.42.0/24 | life, the universe, and everything |
| Surveillance | 84 | 182.168.84.0/24 | Big Brother is watching |
| VOIP | 212 | 192.168.212.0/24 | area code for Manhattan |
Once I had my new network gear configured, I made the stupid decision to stop using Windows and swtiched over to Linux. So while I was cutting my network over to VLANs, I was also reimaging my desktops and my laptop. At one point, desperate for a working computer with both VLAN capability and a physical Ethernet port, I rage purchased a Raspberry Pi 400 from Microcenter.
1. SSH Port Forwarding via Jumphost#
I don’t do much hacker stuff anymore, but back when I did, I would occasionally crash my much flatter home network. Now I my things can get rekt without annoying the family. But, with everything on separate networks and isolated by the firewall, hopping from one VLAN to another requires some old Unix hacker tomfoolery.
In my university days, I lived in an apartment in Northern Kentucky, and I was forever in a fight with my ISP (InsightBB) over open ports on my firewall. Everytime they did their automated scans, I would get kicked off the Internet and have to call them and promise to be a good lad and not open that port. Now I just use a VPS and Headscale.
In the old Unix days, connecting to one host though telnet or ssh and then to another was called “jumping” and the host in the middle was known as a jumpbox. The kids today call them “bastion hosts”. Either way, I use the .ssh/config file to create a kind of shorthand for the jumpbox, which I will call j23.
Note the entries for host. This is a label or a reference rather than a proper hostname. This doesn’t have to be valid hostname or entry in /etc/hosts. It can be anything. You use the label with SSH, which I will explain below.
Add to `~/.ssh/config
# first, define the bastion host/jumpbox
# which is accessible anywhere via headscale
Host j23
HostName 100.23.0.23
User jumpy
# use j23 the jumpbox to the server vlan jumbox, j42
# then forward a local port to port 8006 on the proxmox server
# you can now access the proxmox server at https://127.0.0.1:8006
Host j42
HostName 192.168.42.8
User jumpy
ProxyJump j23
LocalForward 8006 192.168.42.200:8006
# also use j23 to connect to the bare git repo on
# the staging server on the same vlan as j23
Host git
Hostname 192.168.23.3
User gitty
ProxyJump b23
Usage#
# log into j42 via j23 and create that port for proxmox:
ssh j42
# log into git via j23 for use with git
ssh git
# Open tunnel (no shell, just forwarded ports):
ssh -N j42
2. Git: Clone, Checkout, Commit & Push#
When I write a new blog post, I want to preview it on my staging server before it goes live on the Internet. That way I can fix any typos or formatting errors before going live. I don’t want all zero of my readers don’t find out how bad I am at this. Each blog has a git repo for the markdown files that get turned into the published website via Hugo.
So I push my markdown files to a git repo on a staging server, and I use a bunch of git Kung Fu to trigger Hugo to build everything and push it to the staging server. Once it looks right on the staging server, I use a little shell script to push the site live.
Initial setup#
If you haven’t used git before on this machine (which is probably true for a new or reimaged workstation):
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
Then grab your git repo:
git clone git:project1.git
cd project1
git checkout main
Committing changes#
After writing or editing your post:
git add .
git commit -m "your message"
Pushing#
# Push to staging
git push
# When the site is ready to publish
./ship
Conclusion#
With the .ssh/config and the git repo setup on the staging server, I can keep my writing safe in my personal cloud. It is accessible from any laptop or desktop with git and a private key. I have been Linux distro hopping, trying to find the right mix of simple, easy to use, and not too fiddly. With the git repo as the source of truth on a VM that I won’t fiddle with, I can set up my writing environment on a newly imaged desktop with a handful of git commands. It is clumsy at first compared to something like OneDrive, except for the situation where you have changed a bunch of files and you want to tell OneDrive “IDGAF what you have to do, make the newest file available everywhere else”. Git pull will do that every time.