<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: lbonanomi</title>
    <description>The latest articles on DEV Community by lbonanomi (@lbonanomi).</description>
    <link>https://dev.to/lbonanomi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F164266%2F59e23179-d922-4a97-b2cf-effd00af3beb.jpeg</url>
      <title>DEV Community: lbonanomi</title>
      <link>https://dev.to/lbonanomi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lbonanomi"/>
    <language>en</language>
    <item>
      <title>Github "Dimmed" Dark-Mode Images</title>
      <dc:creator>lbonanomi</dc:creator>
      <pubDate>Sun, 19 Jun 2022 16:17:43 +0000</pubDate>
      <link>https://dev.to/lbonanomi/github-dimmed-dark-mode-images-1l4c</link>
      <guid>https://dev.to/lbonanomi/github-dimmed-dark-mode-images-1l4c</guid>
      <description>&lt;p&gt;Hey gang,&lt;/p&gt;

&lt;p&gt;Github supports &lt;code&gt;gh-light-mode-only&lt;/code&gt; and &lt;code&gt;gh-dark-mode-only&lt;/code&gt; for images, does anyone know if there's support for targeting an image to the Dark Dimmed theme?&lt;/p&gt;

&lt;p&gt;TIA!&lt;/p&gt;

</description>
      <category>github</category>
      <category>questions</category>
    </item>
    <item>
      <title>Lecturing About curl-bash Pipelines</title>
      <dc:creator>lbonanomi</dc:creator>
      <pubDate>Tue, 26 Oct 2021 23:11:49 +0000</pubDate>
      <link>https://dev.to/lbonanomi/lecturing-about-curl-bash-pipelines-1ip1</link>
      <guid>https://dev.to/lbonanomi/lecturing-about-curl-bash-pipelines-1ip1</guid>
      <description>&lt;p&gt;Grab some popcorn 'cuz we're here to talk about curl-bash pipelines on Linux. Personally I don't like them for maintenance reasons (how do you remove things you installed like this?), and I want to nag my fellows to not casually run a wall-of-script from the Internet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Interactive vs non-interactive shells
&lt;/h3&gt;

&lt;p&gt;When a bash shell is started at login it's considered &lt;em&gt;interactive&lt;/em&gt; and expects to be attached to a TTY. When we run &lt;code&gt;curl https://example.com/script.sh | bash&lt;/code&gt; the bash process started is &lt;em&gt;non-interactive&lt;/em&gt; and expects no human input. We can confirm a bash process' interactivity either by looking at the process table (run &lt;code&gt;ps&lt;/code&gt;) or by checking the builtin variable &lt;code&gt;$-&lt;/code&gt; (the shell's starting arguments) for an 'i' character.&lt;/p&gt;

&lt;h3&gt;
  
  
  PIDs, Parents and "Siblings"
&lt;/h3&gt;

&lt;p&gt;Part of the classic Unix process model is that a process has a parent that created it and may have child processes that it created. For the purpose of this exercise let's call processes that were created by the same immediate parent process "siblings".&lt;/p&gt;

&lt;p&gt;We can find the current PID's parent with &lt;code&gt;ps -p $$ -o ppid -h&lt;/code&gt;. Running a wide-ranging &lt;code&gt;ps&lt;/code&gt; and grepping for a common parent PID will show us all processes started by the same parent PID as our shell.&lt;/p&gt;

&lt;h3&gt;
  
  
  Seeing connections in procfs
&lt;/h3&gt;

&lt;p&gt;Now that we have a list of all a PID's siblings we can cat-out procfs to see if any of those processes are connected to a known HTTP port.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cat /proc/21456/net/tcp
  sl  local_address rem_address   st tx_queue rx_queue tr tm-&amp;gt;when retrnsmt   uid  timeout inode                                                     
   0: 00000000:2328 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 264000 1 0000000000000000 100 0 0 10 0                    
   1: 00000000:0016 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 264692 1 0000000000000000 100 0 0 10 0                    
   2: 0100007F:0019 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 48214 1 0000000000000000 100 0 0 10 0                     
   3: F71CFE0A:0016 224EFBCF:FBC3 01 00000034:00000000 01:00000015 00000000     0        0 67266130 3 0000000000000000 21 4 17 10 54                 
   4: F71CFE0A:9EE0 856EC7B9:01BB 08 00000000:00000001 02:000012E3 00000000 150001        1 67376561 2 0000000000000000 20 4 0 10 -1                 
   5: F71CFE0A:88D8 0200FE0A:0035 06 00000000:00000000 03:0000028A 00000000     0        0 0 3 0000000000000000                                      
   6: F71CFE0A:89C8 0200FE0A:0035 06 00000000:00000000 03:00001073 00000000     0        0 0 3 0000000000000000                                      
   7: F71CFE0A:960E 98A27032:01BB 01 00000000:00000000 02:000008BC 00000000     0        0 67384497 2 0000000000000000 26 4 6 10 -1                  
   8: F71CFE0A:DC02 71529D36:270D 01 00000000:00000000 00:00000000 00000000     0        0 67343092 1 0000000000000000 20 4 1 10 -1       
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This looks pretty-intense but we're only interested in the last 4 characters (TCP port) of the third column (remote host). These values are all in &lt;em&gt;sigh&lt;/em&gt; hex, so it will be fastest to just grep for a few well-known ports like &lt;code&gt;0050&lt;/code&gt; (80), &lt;code&gt;01BB&lt;/code&gt; (443), &lt;code&gt;1F90&lt;/code&gt; (8080 and &lt;code&gt;20FB&lt;/code&gt; (8443)&lt;/p&gt;

&lt;h3&gt;
  
  
  Putting it all together
&lt;/h3&gt;

&lt;p&gt;Now that we can detect non-interactive shell's children connecting to a well-known web port and suspend their process how do we get this functionality deployed? Let's save our final shell script as /usr/local/bin/blocker.sh:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if [[ $(grep "$(cat /proc/$$/cmdline | tr '\000' "\n" | tail -1)$" /etc/shells) ]]
then
    echo $- | grep -qv i &amp;amp;&amp;amp; ps awwwx -ocmd,pid,ppid | grep "$(ps -p $$ -o ppid -h)$" |  while read p
    do
        sib=$(echo "$p" | awk '{ print $(NF-1) }')
        egrep -q ":0050|:01BB|:1F90|:20FB"  /proc/$sib/net/tcp 2&amp;gt;/dev/null &amp;amp;&amp;amp; kill -SIGSTOP $sib 2&amp;gt;/dev/null &amp;amp;&amp;amp;\
        echo "If you 𝙧𝙚𝙖𝙡𝙡𝙮 want to execute some rando script from the Internet type ctrl-Z and then 𝗳𝗴"
    done | uniq
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and set &lt;code&gt;$BASH_ENV=/usr/local/bin/blocker.sh&lt;/code&gt; to execute our script at startup of every non-interactive bash shell.&lt;/p&gt;

&lt;p&gt;As an example, here's this script pausing an install of Omnitruck&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;; curl -s https://omnitruck.chef.io/install.sh | bash
If you 𝙧𝙚𝙖𝙡𝙡𝙮 want to execute some rando script from the Internet type ctrl-Z and then 𝗳𝗴

[1]+  Stopped                 curl -s https://omnitruck.chef.io/install.sh | bash

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>bash</category>
      <category>linux</category>
    </item>
    <item>
      <title>What was I doing in this shell?</title>
      <dc:creator>lbonanomi</dc:creator>
      <pubDate>Sat, 14 Nov 2020 14:09:18 +0000</pubDate>
      <link>https://dev.to/lbonanomi/what-was-i-doing-in-this-shell-4i9b</link>
      <guid>https://dev.to/lbonanomi/what-was-i-doing-in-this-shell-4i9b</guid>
      <description>&lt;p&gt;Do you frequently open another SSH window for another task or to connect to another machine? I know I do. Do you ever return to those windows a day or two later and wonder what you were doing there to begin-with? I know I do.&lt;/p&gt;

&lt;p&gt;Put this into your .profile to to run the &lt;code&gt;lulwat&lt;/code&gt; function any time you hit enter three times in a row.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# source me.

export PROMPT_COMMAND=btnMash

function btnMash {
  # Init a counter for prompts-displayed if its missing
  [[ -f /tmp/promptsDisplayed ]] || history | tail -1 | awk '{ print $1 }' &amp;gt; /tmp/promptsDisplayed;

  # Init a counter for commands
  [[ -f /tmp/commandsRun ]] || (history | tail -1 | awk '{ print $1 }' &amp;gt; /tmp/commandsRun)

  COMMANDS=$(cat /tmp/commandsRun)

  # Increment prompts-displayed counter
  echo $(($(cat /tmp/promptsDisplayed)+1 )) &amp;gt; /tmp/promptsDisplayed;

  history | tail -1 | awk '{ print $1 }' &amp;gt; /tmp/commandsRun

  if [[ $COMMANDS -lt $(cat /tmp/commandsRun) ]]
  then
    cat /tmp/commandsRun &amp;gt; /tmp/promptsDisplayed
  fi

  PROMPTS=$(cat /tmp/promptsDisplayed)

  if [[ $PROMPTS -ge $(($COMMANDS+3)) ]]
  then
    lulwat; rm /tmp/promptsDisplayed; return
  fi
}

function lulwat {
    # If I am su-ed into this account, tell me.
    #
    ID=$(id | awk '{gsub(/[\(-\)]/," ")} { print $2 }');
    WHO=$(who -m | awk '{ print $1 }')

    [[ "$ID" == "$WHO" ]] &amp;amp;&amp;amp; echo "You are: $ID"
    [[ "$ID" == "$WHO" ]] || echo "You are: $ID (su-ed from $WHO)"

    # Hostname and path
    #
    printf "On: $(hostname):$(pwd)\n"

    # If this a git repo, remind me of the remote
    #
    git status &amp;amp;&amp;gt;/dev/null &amp;amp;&amp;amp; (
        printf "$(git remote -vv | awk '{ print $2 }' | head -1) ($(git branch | awk '{ print $2 }'))\n"
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>bash</category>
      <category>linux</category>
    </item>
    <item>
      <title>Cheap sudo tricks</title>
      <dc:creator>lbonanomi</dc:creator>
      <pubDate>Sat, 01 Aug 2020 14:15:40 +0000</pubDate>
      <link>https://dev.to/lbonanomi/cheap-sudo-tricks-3o8o</link>
      <guid>https://dev.to/lbonanomi/cheap-sudo-tricks-3o8o</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;It's easier to ask forgiveness than it is to get permission.&lt;br&gt;
-- Grace Hopper&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I've done ops work under various titles for various employers for the last 15 years. If memory serves &lt;em&gt;every&lt;/em&gt; one of them has given the ops-geeks &lt;code&gt;sudo&lt;/code&gt; rules that allowed &lt;code&gt;sudo chmod&lt;/code&gt; and &lt;code&gt;sudo chown&lt;/code&gt; to run as root, but would choke on a request for &lt;code&gt;sudo -i&lt;/code&gt;. Here's why that's a stupid policy:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create an SSH key on your local box if you don’t have one already.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connect to a target box, and cd to ~roleaccount.&lt;br&gt;
If ~roleaccount/.ssh exists, change permissions on it to allow you to read and write. Otherwise, create ~roleaccount/.ssh&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;cd to ~roleaccount/.ssh and &lt;code&gt;sudo chmod o+wx&lt;/code&gt; authorized_keys.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Edit the authorized_keys file to append your public key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Restore permissions on authorized_keys&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go up to ~roleaccount and restore permissions on .ssh&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From your local box: ssh roleaccount@target_host&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you reset permissions correctly, you have just connected directly as roleaccount.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This isn't a stealthy method of switching to another user, so please be ready to explain yourself if there's an audit.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>security</category>
    </item>
    <item>
      <title>Yet another Github Profile</title>
      <dc:creator>lbonanomi</dc:creator>
      <pubDate>Sat, 11 Jul 2020 19:32:31 +0000</pubDate>
      <link>https://dev.to/lbonanomi/yet-another-github-profile-4ai</link>
      <guid>https://dev.to/lbonanomi/yet-another-github-profile-4ai</guid>
      <description>&lt;p&gt;I can't find anything to say about Github profiles that hasn't been posted already so I'll ask a question instead: does anyone know the recommended daily allowance of Perl? &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/lbonanomi/"&gt;https://github.com/lbonanomi/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Hints For Engineers During Outages</title>
      <dc:creator>lbonanomi</dc:creator>
      <pubDate>Fri, 22 May 2020 10:43:03 +0000</pubDate>
      <link>https://dev.to/lbonanomi/hints-for-engineers-during-outages-109h</link>
      <guid>https://dev.to/lbonanomi/hints-for-engineers-during-outages-109h</guid>
      <description>&lt;ul&gt;
&lt;li&gt;Don't make jokes in a logged channel. &lt;em&gt;Every&lt;/em&gt; written record will be read by someone with more clout and less sense of humor than you.&lt;/li&gt;
&lt;li&gt;Don't feel like you have to offer an opinion if you weren't asked for one. Its okay to look and listen before saying anything. &lt;/li&gt;
&lt;li&gt;Be &lt;em&gt;high tea with the Queen&lt;/em&gt; level courteous. Angry people make &lt;strong&gt;bad&lt;/strong&gt; decisions, and people can stay mad for a long time.&lt;/li&gt;
&lt;li&gt;Excuse yourself from small outage calls if you need to attend to something. Excuse yourself to your direct manager for large outage calls.&lt;/li&gt;
&lt;li&gt;Management has an agenda you don't know about, avoid getting into territory battles above your paygrade.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>sre</category>
    </item>
    <item>
      <title>Your Own Gravatar.com</title>
      <dc:creator>lbonanomi</dc:creator>
      <pubDate>Fri, 01 May 2020 11:06:40 +0000</pubDate>
      <link>https://dev.to/lbonanomi/your-own-gravatar-com-56ee</link>
      <guid>https://dev.to/lbonanomi/your-own-gravatar-com-56ee</guid>
      <description>&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;After a a few years of running Jira as a pool of federated servers, management decided to let us consolidate into a Jira Datacenter cluster. We provisioned extremely beefy VMs, allocated huge disks and got a dedicated Postgres cluster. Projects were imported, attachments migrated and we were pretty pleased with ourselves until the user feedback started: we hadn't imported the user's custom avatars correctly and rapid boards looked like hot garbage. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Zg1bM9Gr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cwp4gg5yqfy6qkh506q0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zg1bM9Gr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cwp4gg5yqfy6qkh506q0.png" alt="Broken Jira avatars"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://confluence.atlassian.com/jirakb/custom-avatars-missing-after-upgrade-or-migration-of-jira-server-224395280.html"&gt;vendor's instructions&lt;/a&gt; are geared toward moving whole instances from one platform to another, which didn't fit our model of merging multiple Jiras together. After some deliberation we decided to try hosting avatars on an independent server.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hosting your own Gravatar server
&lt;/h3&gt;

&lt;p&gt;After experiments with the API, and a discussion about making changes directly in the database we decided to try using a custom avatar server. After a surprisingly frustrating day trying to get &lt;a href="https://www.libravatar.org/"&gt;Libravatar&lt;/a&gt; on RHEL7, we settled on the comparatively simpler  Go project &lt;a href="https://github.com/bertbaron/intravatar"&gt;intravatar&lt;/a&gt;. Intravatar offers &lt;a href="https://github.com/bertbaron/intravatar/releases"&gt;binaries&lt;/a&gt; that work beautifully right out of the box, but we made a few simple changes to accommodate our MitM SSL and Internet proxying. Now that we have a place to serve them from, let's get avatars!&lt;/p&gt;

&lt;h3&gt;
  
  
  Grabbing Jira avatars
&lt;/h3&gt;

&lt;p&gt;Jira stores avatar files under &lt;code&gt;$JIRA_HOME/data/avatars&lt;/code&gt; in the format of $ID_$name, so we used the REST API to associate usernames and avatar files. The below bash script will get a list of users from the Jira database, parse details from the user endpoint and scrape the instance's avatar URL to get a file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/bash

# Database connection string is intentionally vague.
psql -tc "select lower_user_name from cwd_user;" | while read USER
do
    curl -snk "https://$OLD-JIRA/rest/api/2/user?username=$USER" | jq .avatarUrls | grep 48 | grep -q $OLD-JIRA &amp;amp;&amp;amp; (
        # Get old avatar
        FILE=$(curl -snk "https://$OLD-JIRA/rest/api/2/user?username=$USER" | jq ."emailAddress" | tr -d '"' | tr -d "\n" | md5sum - | awk '{ print $1 }')
        URL=$(curl -snk  "https://$OLD-JIRA/rest/api/2/user?username=$USER" | jq .avatarUrls | grep 48 | awk -F"\"" '{ print $4 }')

        echo "$URL" | grep gravatar &amp;amp;&amp;amp; (
            curl -snk $URL &amp;gt; $FILE
        )

        echo "$URL" | grep gravatar || (
            curl -snk &amp;gt; $FILE
        )
    )
done
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;My team &amp;lt;3s &lt;a href="https://github.com/bertbaron"&gt;Bert Baron&lt;/a&gt; and &lt;a href="https://github.com/bertbaron/intravatar"&gt;intravatar&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>gravatar</category>
      <category>jira</category>
    </item>
    <item>
      <title>Quick Checks for Log Repetition</title>
      <dc:creator>lbonanomi</dc:creator>
      <pubDate>Sun, 26 Apr 2020 11:21:35 +0000</pubDate>
      <link>https://dev.to/lbonanomi/quick-checks-for-log-repetition-20ba</link>
      <guid>https://dev.to/lbonanomi/quick-checks-for-log-repetition-20ba</guid>
      <description>&lt;p&gt;Got paged at 06:30, second disk alert on an Apache proxy in 24 hours.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ tail -500 access_log | awk '{ print $11 }' | while read l ; 
do echo "$l" | cksum; done | sort | uniq -c | sort -rnk1
    254 646511054 1131
    241 4112021984 1128
      1 785623522 964
      1 3691076460 4
      1 3287357281 899
      1 2484884658 1131
      1 2437517015 72
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Looks like 99% of requests are the same 2 things. Eyeballing demonstrates my hosts are getting polled hard by a user. They are suspended until they explain what they are doing to generate ~15 gigs of logging all by themselves every 20 hours.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>sysops</category>
    </item>
    <item>
      <title>Hints For Managers During Outages</title>
      <dc:creator>lbonanomi</dc:creator>
      <pubDate>Wed, 12 Feb 2020 00:49:01 +0000</pubDate>
      <link>https://dev.to/lbonanomi/hints-for-managers-during-outages-57l6</link>
      <guid>https://dev.to/lbonanomi/hints-for-managers-during-outages-57l6</guid>
      <description>&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If you talk to another engineer privately about &lt;em&gt;our problem&lt;/em&gt; while I am on-task I will consider the problem assigned to someone else and find another chore. If you talk to another engineer about &lt;em&gt;me&lt;/em&gt; privately, expect both of us to waste valuable time arguing with each other instead of fixing something.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you say "can we X?" when you mean "Do X." I will start considering everything you say to be a conversation starter instead of an instruction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you drop off our outage call to attend to another regularly scheduled meeting "our" problem will lose urgency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you schedule a group status call and then fail to join it because you were informed out-of-band I will assume law of the jungle and feel free to update your manager about my progress directly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you miss the group status call without explanation and then ask for a status, please expect little.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Your&lt;/em&gt; decision did not retroactively become &lt;em&gt;our&lt;/em&gt; decision because something broke.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>sre</category>
    </item>
    <item>
      <title>What's New at The Book of Secret Knowledge</title>
      <dc:creator>lbonanomi</dc:creator>
      <pubDate>Mon, 02 Dec 2019 12:57:37 +0000</pubDate>
      <link>https://dev.to/lbonanomi/what-s-new-at-the-book-of-secret-knowledge-4i3i</link>
      <guid>https://dev.to/lbonanomi/what-s-new-at-the-book-of-secret-knowledge-4i3i</guid>
      <description>&lt;p&gt;Do you follow &lt;a href="https://github.com/trimstray/the-book-of-secret-knowledge"&gt;The Book of Secret Knowledge&lt;/a&gt; on Github? &lt;/p&gt;

&lt;p&gt;Here's a &lt;a href="https://botonomi.github.io/BoSK-Watch/feed.xml"&gt;full-content RSS feed&lt;/a&gt; of recent changes.&lt;/p&gt;

</description>
      <category>github</category>
      <category>rss</category>
    </item>
    <item>
      <title>Provider Shells</title>
      <dc:creator>lbonanomi</dc:creator>
      <pubDate>Fri, 08 Nov 2019 01:03:53 +0000</pubDate>
      <link>https://dev.to/lbonanomi/provider-shells-1d03</link>
      <guid>https://dev.to/lbonanomi/provider-shells-1d03</guid>
      <description>&lt;p&gt;There are a ton of Linux users on dev.to, do any of you use remote Linux shell services or is everyone operating off of their PCs and laptops? &lt;/p&gt;

&lt;p&gt;Am I trapped in 1995?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>linux</category>
      <category>unix</category>
    </item>
    <item>
      <title>SSH Shibboleths </title>
      <dc:creator>lbonanomi</dc:creator>
      <pubDate>Tue, 05 Nov 2019 12:40:13 +0000</pubDate>
      <link>https://dev.to/lbonanomi/ssh-shibboleths-3p5b</link>
      <guid>https://dev.to/lbonanomi/ssh-shibboleths-3p5b</guid>
      <description>&lt;p&gt;I'm a bad meeting attendee; 5 minutes into any slide deck I retreat into &lt;a href="https://www.shadowruntabletop.com/"&gt;paranoid fantasies of network espionage&lt;/a&gt;. Last budget session fantasy-me needed a subtle back channel to indicate that I was operating from a compromised position, so regular me hacked-together a working prototype with bash init scripts, SSH key features, and a little-used SSH config file. &lt;/p&gt;

&lt;h5&gt;
  
  
  Commands in SSH keys
&lt;/h5&gt;

&lt;p&gt;It's probably common knowledge that key values in the SSH &lt;code&gt;authorized_keys&lt;/code&gt; file can be &lt;a href="https://www.ssh.com/ssh/authorized_keys/openssh#sec-Format-of-the-Authorized-Keys-File"&gt;locked to a single command&lt;/a&gt;, so I'll just say that the regularly used SSH key for this system was altered to start with &lt;code&gt;command="exec bash"&lt;/code&gt; to start an interactive shell. &lt;/p&gt;

&lt;h5&gt;
  
  
  sshrc
&lt;/h5&gt;

&lt;p&gt;Hosts using the OpenSSH daemon will process a user's &lt;code&gt;$HOME/.ssh/rc&lt;/code&gt; file &lt;em&gt;before&lt;/em&gt; sourcing the user's shell init scripts. By default sshd will not allow environment variables to be exported, but will happily execute shell scripts, so a simple instruction to run &lt;code&gt;touch $HOME/.ssh.lck&lt;/code&gt; was added to create a lockfile. This has the helpful side-affect of not messing with console logins. &lt;/p&gt;

&lt;h5&gt;
  
  
  bashrc
&lt;/h5&gt;

&lt;p&gt;Last stop is to modify &lt;code&gt;.bashrc&lt;/code&gt; to look for the &lt;code&gt;~/ssh/rc&lt;/code&gt; lockfile, set &lt;code&gt;$PROMPT_COMMAND&lt;/code&gt; to execute a function for password-auth vs. ssh key-auth, and remove the lockfile.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; .ssh.lck &lt;span class="o"&gt;]]&lt;/span&gt;
&lt;span class="k"&gt;then
        if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;ps axwww | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'$1 == '&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$$&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s1"&gt;' { print $NF }'&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"bash"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;
        &lt;span class="k"&gt;then
                function &lt;/span&gt;passworded&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"User is password-authenticated"&lt;/span&gt;
                        &lt;span class="nb"&gt;unset &lt;/span&gt;PROMPT_COMMAND
                &lt;span class="o"&gt;}&lt;/span&gt;
                &lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PROMPT_COMMAND&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"passworded"&lt;/span&gt;
        &lt;span class="k"&gt;fi

        &lt;/span&gt;&lt;span class="nb"&gt;rm&lt;/span&gt; .ssh.lck 2&amp;gt;/dev/null
&lt;span class="k"&gt;else
        function &lt;/span&gt;keyed&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"User is SSH key-authenticated"&lt;/span&gt;
                &lt;span class="nb"&gt;unset &lt;/span&gt;PROMPT_COMMAND
        &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PROMPT_COMMAND&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"keyed"&lt;/span&gt;

        &lt;span class="nb"&gt;rm&lt;/span&gt; .ssh.lck 2&amp;gt;/dev/null
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;passworded&lt;/code&gt; and &lt;code&gt;keyed&lt;/code&gt; functions should of course be tailored for your needs.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
      <category>ssh</category>
    </item>
  </channel>
</rss>
