Easier SSH with Config

As long as I’ve been using SSH, I only recently started using SSH Config.

I have many Linux computers (Raspberry Pis, desktops and laptops) on my local network. It’s difficult to remember each computer’s IP address and username when using SSH. SSH Config allows you to define ssh connection options in one location. Note: SSH Config is available on Mac and Linux when using OpenSSH Client.

Given the following ~/.ssh/config file:

Host pi3b
    HostName 192.168.1.245
    User pi
Host pizerow
    HostName 192.168.1.210
    User pi

The SSH command ssh pi@192.168.7.245 is replaced with ssh pi3b .

Common Options

Below is a list of common options used in ~./ssh/config. A full list of config option are available at ssh.com.

HostName – IP address or URI to a remote computer

User – SSH username

Port – SSH port different than the default 22

IdentityFile – Specify a specific key file

ForwardAgent – (no/yes) Allow SSH server access to client SSH Agent for sharing SSH keys

Example:

Host stephencross
   HostName ssh.stephencross.com
   User sshuser
   Port 2222
   IdentityFile ~/.ssh/stephencross.pub

Host Matching

SSH options are used for all Hosts that match from top down in the config file. Given the follow ~/.ssh/config file:

Host pi3b
    HostName 192.168.1.245
Host pizerow
    HostName 192.168.1.210
Host picm4
    HostName 192.168.1.234
Host pihole
    HostName 192.168.1.134
    User piadmin
Host nuc
    HostName 192.168.1.196
    User stephencross
Host pi*
    User pi
Host * !nuc
    Compression yes
  • Host pi* – User is set to ‘pi’ for all Hosts that begin with ‘pi’. Because Host pihole has User define higher in the file, it’s user name is ‘piadmin’
  • Host * !nuc – Compress is ‘on’ for all Hosts, except Nuc

In Summary

SSH Config is easy to setup and a big time saver.

Moving to VIM

After 30 years in front of the keyboard, I decided to refine my craft and learn to touch type. It’s been about a month, and I’m improving. Keeping my fingers on “home keys” got me thinking about how often I remove them to touch the mouse. All these keys at my finger tips and they are almost useless for navigation within a file. Hello Vim.

I’ve used Vim for editing text files on a server for years. I knew the basics: insert mode, save, and exit. One of the powerful features of Vim is its modes. The two primary modes are Normal and Insert. When in normal mode, the keys are used to navigate, copy and paste, find, and much more. You don’t need to mouse or cursor keys; in fact, you shouldn’t be using them. To modify text, you enter insert mode, which is the only mode in most text editors. The capabilities of Vim are mind-blowing.

To get started, I watched several videos on Youtube and began a slow transition. While it’s a gradual transition, you will see the benefits quickly. I hope to replaced VS Code with Vim someday. I love the idea of using the same tool proficiently on a desktop, VPS, or Raspberry Pi.

How to get started

My recommendation:

  1. Vim Mode – using your existing IDE, such as VS Code, adding a Vim extension to give you basic Vim workflow and key bindings. This is a good bridge from where you are today to Vim 100%.
  2. Six Part Series – Recently, Youtuber, The Primeagan, released an excellent six part series to learn Vim. His videos are educational and entertaining. Watch video 1 and don’t moved to the second video until you don’t need to think about basic navigation keys. I’m not through them all yet.
  3. Explore – There are many Vim tutorial available online. You them to explore the capabilities of Vim to do things easier and faster.

Improve your family gatherings over Zoom

It’s the spring of 2020, and we are all quarantined. Video conferencing tools, like Zoom, are being used daily for work and play. Family chats, games nights, and parties are a regular occurrence in the Cross family.

One of the challenges with family video conferences is when you have multiple people in the same home using separate devices. People scatter to different areas of the house so they can be seen and heard without echos and feedback, which defeats the purpose of gathering together. In the business world, people sit around a conference table and use a conference phone. Everyone uses a single microphone and speaker placed in the center of the table. You can setup the same configuration using a USB conference microphone.

At my home, we all sit at the dining room table with our computers or iPads connected to the Zoom call, and one computer connects to the audio on the Zoom call. All others connect to Zoom video-only. The audio designated computer connects to a USB conference microphone and uses that as the microphone.

I have a mic from MXL, the AC404 USB Conference Mic. It’s one of those things you don’t use often, but it’s very handy when the time comes, such as, a Football Fantasy Draft and Quarantine Party. There are a variety USB Conference mics available from $30 to $100.

WordPress

This website, stephencross.com, has mostly been a place for me to play with new technology. Moving forward, I’m going to play somewhere else, and use this location to share information.

This time around I’m using WordPress. I picked a simple theme, and copied a few posts from the previous version of stephencross.com. I haven’t used WordPress in many years. I’m impressed how quickly I was able to put this website together and feel comfortable publishing the first draft.

Recovering Home Video

I have forty-six tapes with home videos that cover family events from 1996 to 2005. These tapes have been stored in a box for as many years. I recently took on the project of moving them to a format we can enjoy. My two challenges: how to get them off of the tapes and how to make them accessible to everyone in the family.

Camera to Computer

The camera used to take these videos, a Sony Digital HandyCam DCR TRV 120 , is still operational. I made that discovery after purchasing a power cord from Amazon. Then I needed cabling to connect the camera to my computer. This was hit and miss because it wasn’t clear to me which cables would work. I’m thankful Amazon has a generous return policy. I had three cable attempts fail. I settled on a combination of two cables that allowed me to go from a 1/4 inch camera output to composite and then composite to USB. The composite to USB came with drivers and software to capture video on a Mac.

Cables:

HDE 3ft. Feet RCA Male to 3.5mm Male Jack Composite Audio Video A/V Cable

S-Video / Composite to USB Video Capture Cable Adapter w/ TWAIN and Mac Support – VHS to USB Composite Svideo

Capture Process

The capture process requires each tape to be played from the camera and recorded on the Mac. A 45-minute recording takes 45 minutes to capture. I learned the capture process is a bit fragile. After recording eighteen videos (aka eighteen hours of recording), I discovered eleven videos had no audio or the audio was out of sync. I made some changes to my process to ensure the remaining recording would go well.

  • The video capture software should be the only application running on the Mac during the capture process
  • Play the audio through the Mac, not the camera, to verify the audio is getting to the camera
  • Rebooted at the start of each recording session or after every four tapes

Some tapes had sixty minutes of content while others had thirty-five. The best process for me was to let the 60-minute tape run through and edit out the blue screen when it completed. This allowed me to do other things while capturing the video. When the recording was complete, I would open the resulting .mov file in QuickTime and trim out the blank recording from the end.

Serving Home Video

I chose to serve the home videos through Plex. Plex allows you to store, manage, and stream your personal media. I expect I will be using Plex home movies and maybe photos in the future. Plex is an open source application that requires a central server to stream content to Plex clients. A Plex client can be almost any device. For me it will be Apple TV, iPads, iPhones, a Roku, and Fire TVs. Content can be streamed in and out of my home network. With grown-up children, having remote access to the video content is important.

After a bit of research, I learned that a Raspberry Pi could be used as a server, but it may not be powerful enough. Since I had a Pi 3, I decided to give it a try. Comfortable with Linux and the command line, I had a Plex server running on the Pi in 15 minutes using a resource like How to set up a Raspberry Pi Plex server. I connected a USB external drive to the Pi to store the 140GB of home videos.

It worked! The quality of the video is fantastic. When streaming a 30-minute video from a device, it will stop a few times and buffer. A “your server is not powerful enough…” type message will also appear, but it works. (See Update 12-31-18 below)

Next Steps

Plex Server Upgrade – My next project is to upgrade the $35 Raspberry Pi to a more powerful single board computer (SBC). I’m looking at a RockPro64 or NanoPC T4 with 250GB m.2 storage. I think this will deliver my minimal needs and not break the bank. And more importantly, it’s a fun tech project. Stay tuned. (See Update 12-31-18 below)

Video Editing – I discovered that the 19-year-old video labeled as Christmas 1999, was really four events starting in December, 1999 and ending in July, 2000. Now that I have the videos on my computer, I’ll be breaking them into smaller videos. No commitment on when this will be complete.

Moving forward – We all take lots of video with our smartphones. For me, it’s not intentional, long-form video, like my Digital 8 tapes. It’s short bursts of interesting things. Moving forward, I need to figure out how to aggregate that video in a format my kids can enjoy in 25 years.

UPDATE: 12-31-18

It turns out, I don’t need to upgrade the Raspberry Pi, I just needed to educate myself on video formats, transcoding, and Plex. As I utilize more features of Plex in the future, I may need more power than a Raspberry Pi 3 provides, but for now, it will work fine to serve my fifty home movies.

The power of Plex is its ability to transcode video for the device viewing the content. When converting my video from tape to digital, I create .mov files. When viewing these videos on Apple TV or iPads, they are transcoded from MPEG to H.264. This is a CPU heavy process.

Plex provides the ability to pre-optimize videos and save them on the server. For my videos, that format is H.264 at 480p resolution. When viewing a pre-optimized video, Plex doesn’t need to transcode the video, just stream it, which is not CPU intensive. This is called Direct Play.

When you have a low powered Plex server, like a Raspberry Pi, the goals is to Direct Play all videos by pre-optimizing them for the devices they are viewed on.

Pre-Optimizing is very easy. You simply choose one or more videos and select the Optimize option. Since this process is CPU intensive, it may take a long time for each video, but it’s only a one-time process.

Static Websites with Sculpin

his blog, on 8/14/18, is static HTML generated by Sculpin, a static site generator written in PHP. Sculpin converts Markdown files, Twig templates and standard HTML into a static HTML site that can be easily deployed.

What is a Drupal guy doing with a static HTML website? Truthfully, just tinkering with technology. I like the idea of simplifying and minimizing. For simple blog, is it necessary to have a sophisticated content management system using a database and generating a website dynamically? That’s the question I’m exploring with Sculpin.

Why Scuplin? There are many frameworks available for generating an HTML website, the most popular is Jekyll, like Sculip, it’s open source, but built on Ruby and Liquid. Sculpin is a built on PHP and Twig, which pairs nicely with my Drupal experience. It was an easy decision to start with Sculpin. I may take a look at other Ruby and Python options in the future.

I’m not a Sculpin expert, but I’m learning. I downloaded the sample blog implementation to use as a working reference. Following the Sculpin Getting Started instructions, I quickly had the sample website running on my local computer. After looking through the sample website code and documentation I started a new website. I used a simple bootstrap theme, converted it to TWIG and had my blog running in a few evenings.

Sculpin Basics

Content

Content resides in a markdown files (.md). In my blog implementation, the content is either a blog post or simple page. In Drupal terms, this content is known as an Article or Basic Page. To create a new blog post, I simply create a new markdown file with some meta data at the top of the file. The example below is a blog post with meta data.

---
title: At home on July 4th
author: Stephen Cross
tags:
    - Life
primary_image: /images/blog/home_primary.jpg
primary_image_alt: Mantle with patriotic HOME sign
list_image: /images/blog/home_list.jpg
list_image_alt: Mantle with patriotic HOME sign
---

It's July 1st.  In most parts of the US, that means three days until a day off to celebrate the nations birthday.  In Bristol RI it has a very different meaning.  The 4th of July is a significant event, it's THE event.   Planning for July 4th, starts on July 5th the previous year.   The celebration begins in June and climaxes with the oldest parade in the country.   

...

We are days away from our second 4th hosting.   It's exciting to have family and friend join us for this purely American, hometown celebration.  

Happy 4th.

Templates

Sculpin uses Twig for a templating engine. Twig is straight forward and there is an abundance of references on-line.

Generate

When your templates are setup, and you have some content, you then generate the website. Scuplin use the markdown and templates to output a stand alone HTML website.

vendor/bin/sculpin generate

Sculpin also provides a web service to view your website locally as you work on it. The command below kicks off the service, which monitors your source code and automatically refreshes the HTML as you update markdown and templates. I can view the website at http://localhost:8001.

vendor/bin/sculpin generate --watch --server --port=8001
Detected new or updated files

Generating: 100% (221 sources / 0.00 seconds)
Converting: 100% (232 sources / 0.08 seconds)
Formatting: 100% (232 sources / 0.01 seconds)
Processing completed in 0.13 seconds
Starting Sculpin server for the dev environment with debug true
Development server is running at http://localhost:8001
Quit the server with CONTROL-C.

Deployment

When development is complete, you generate HTML to a new folder, /output_prod:

vendor/bin/sculpin generate --env=prod

You can then push the HTML to the webserver with an scp or rsync.

rsync -avze ssh  output_prod/ user@website.com:/var/www/html --delete

Workflow

After the website is built, the daily workflow is:

  1. Create new post in a markdown file, ie. _post/2018-08-01-Hello-World.md
  2. Generate HTML
  3. Push HTML to Server

For me, these are manual steps, but I plan to change this workflow to use a continuous deployment strategy. As I push updates to my git repo, the HTML will be automatically generated and pushed to the server.

Benefits

Although I’ve recently started using Sculpin and my knowledge is limited, I see the benefits as:

  • Performnace – HTML websites are super fast.
  • Low powered production server – The website can run on almost anything. The only runtime requirement is a web server. It have StephenCross.com running on the smaller Digital Ocean VPS with only apache install. I look forward to trying a Rasberry PI.
  • Low maintenance – I don’t have to worry about frequent stack updates.
  • Backup – While I’m backuping up the server weekly, it’s not necessary. The content and tools are on my local computer and in a git repo.

Cons I haven’t found many drawback yet. I do find the documentation sparse with few online examples and resources.

Next Steps

I see the next steps as:

  • Implement a CI process
  • Implement a search mechanism
  • Add sidebar to view by category

Check back for updates!

Resources

Updates

8/16/18 – Added SSL. It’s pretty straight forward to add SSL following this community post on Digital Ocean for Let’s Encrypt.

8/17/18 – Added Disqus for commenting. Sculpin provides this capability.

11/28/19 – Time for a changed, still like sculpin, but going to checkout WordPress.

When Software Lifts Hardware – Outcast on Apple Watch

Over the past year, I’ve prioritized exercise in my life, most days spending an hour outside or at the gym. I take advantage of that time to listen to podcasts and audiobooks. It took two devices to make this work for me, a health tracker (Fitbit) and phone (iPhone).

While I had wanted an Apple Watch since it’s introduction, having the ability to leave your phone behind made the Series 3, released in October 2017, a compelling product. I upgraded my Fitbit to an Apple Watch, Series 3 Cellular, shortly after its release.

My dreams of untethering from my iPhone during my 3.5-mile walk vanished quickly. While the Series 3 Cellar Apple Watch works well without my phone, it doesn’t support podcast playback from Apple’s Podcast app, and Apple has not made it easy for developers to create podcast apps. In fact, the podcast app I use, Overcast, removed their support for Apple Watch with the release of watchOS 4. Also, there is no Audible playback on the Apple Watch.

I was happy with my move from Fitbit to Apple Watch, but I was still talking my phone with me, which is frustrating when I have a capable computer on my wrist. I tried a few apps claiming to support podcast playback on the Apple Watch, but they were too hard to use and very unreliable.

Then along came Outcast! While not perfect, the folks at Crunchy Bagel battled through Apple’s developer limitations and created an app that works. While Outcast allows you to search and enter podcast feeds to the app manually, I was able to import my existing podcast list from my podcast App Overcast. In a few minutes, I was running the bike path, listening to the Vector with Rene Richie podcast while my iPhone was on the charger at home.

A $.99 app lifted the value of my Apple Watch, to me.

I now wait for Apple to provide the watchOS features developers need to create a quality experience. Hey Audible, what up?