<?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: C.J. Windisch</title>
    <description>The latest articles on DEV Community by C.J. Windisch (@cj_windisch).</description>
    <link>https://dev.to/cj_windisch</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%2F1004334%2F0ac5b9ae-0a67-427e-b03f-b80e340d1198.jpg</url>
      <title>DEV Community: C.J. Windisch</title>
      <link>https://dev.to/cj_windisch</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cj_windisch"/>
    <language>en</language>
    <item>
      <title>What dataset do you wish existed but doesn’t?</title>
      <dc:creator>C.J. Windisch</dc:creator>
      <pubDate>Mon, 16 Jan 2023 14:38:51 +0000</pubDate>
      <link>https://dev.to/cj_windisch/what-dataset-do-you-wish-existed-but-doesnt-4lka</link>
      <guid>https://dev.to/cj_windisch/what-dataset-do-you-wish-existed-but-doesnt-4lka</guid>
      <description>&lt;p&gt;I’ve been interested in monetizing some side projects, and I’ve seen some really good small businesses that exist just by providing an api layer over a data set they’ve worked to collected. I’m interested in what people have needed (especially for ml) when they found there wasn’t a rebuilt dataset out there and it stopped them from pursuing a project.&lt;/p&gt;

</description>
      <category>gratitude</category>
      <category>writing</category>
    </item>
    <item>
      <title>Automatically Update Security Group When SSHing into Your Server</title>
      <dc:creator>C.J. Windisch</dc:creator>
      <pubDate>Tue, 10 Jan 2023 04:10:11 +0000</pubDate>
      <link>https://dev.to/cj_windisch/automatically-update-security-group-when-sshing-into-your-server-24l7</link>
      <guid>https://dev.to/cj_windisch/automatically-update-security-group-when-sshing-into-your-server-24l7</guid>
      <description>&lt;p&gt;Often times I’m working from a coffee shop, a friend or family members house, an airport, or somewhere else random. Then I try to ssh into my server to do something and it hangs. &lt;/p&gt;

&lt;h3&gt;
  
  
  Troubleshooting EC2 SSH Connection Issues
&lt;/h3&gt;

&lt;p&gt;SSH is not particularly helpful in informing you what's happening when you're trying to fix EC2 SSH problems. Eventually I realize there's an EC2 SSH connection timeout because I have to add my IP to the security group before I can ssh.&lt;/p&gt;

&lt;p&gt;I made a useful bash script and shortcut to check if ssh is available and if not use the aws cli to add my current ip to the security group then try again.&lt;/p&gt;

&lt;p&gt;I know, probably not great adding a public network IP to the security group, but when you gotta get work done you gotta get work done.&lt;/p&gt;

&lt;p&gt;Here’s the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
&lt;span class="k"&gt;function &lt;/span&gt;ssh_into_ec2&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nv"&gt;HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ec2-11-111-11-111.us-east-2.compute.amazonaws.com"&lt;/span&gt; &lt;span class="c"&gt;# Change to your region and ec2 public url&lt;/span&gt;
  &lt;span class="nv"&gt;USER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ec2-user &lt;span class="nv"&gt;SSH_STRING&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ec2-user@&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="c"&gt;# Change if you use a different username&lt;/span&gt;
  &lt;span class="nv"&gt;HOST_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nv"&gt;SSH_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your-key-file.pem &lt;span class="c"&gt;# point to your keyfile&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Checking if ssh to &lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt; is reachable"&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;timeout &lt;/span&gt;2 nc &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="nv"&gt;$HOST&lt;/span&gt; 22&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Reachable. SSHing into &lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    ssh &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nv"&gt;$SSH_KEY&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$USER&lt;/span&gt;&lt;span class="s2"&gt;@&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;else
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"ssh to &lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt; not reachable, adding current IP to security group"&lt;/span&gt;
    &lt;span class="nv"&gt;SECURITY_GROUP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your-security-group"&lt;/span&gt; &lt;span class="c"&gt;# Change to the name of your EC2 server's security group&lt;/span&gt;
    &lt;span class="nv"&gt;PUBLIC_IP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl ifconfig.me&lt;span class="si"&gt;)&lt;/span&gt;
    aws ec2 authorize-security-group-ingress &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;--group-name&lt;/span&gt; &lt;span class="nv"&gt;$SECURITY_GROUP&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;--protocol&lt;/span&gt; tcp &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;--port&lt;/span&gt; 22 &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;--cidr&lt;/span&gt; &lt;span class="nv"&gt;$PUBLIC_IP&lt;/span&gt;/32
    ssh &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nv"&gt;$SSH_KEY&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$USER&lt;/span&gt;&lt;span class="s2"&gt;@&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Resources that helped make the code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/a/35741530/10302179" rel="noopener noreferrer"&gt;How to find if a server is reachable over ssh&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/40778261/stop-script-if-nc-connetion-succeded-in-bash" rel="noopener noreferrer"&gt;How to check if nc succeeded in a bash script&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/a/26675771/10302179" rel="noopener noreferrer"&gt;How to check the exit status using an if statement&lt;/a&gt;&lt;br&gt;
&lt;a href="https://constellix.com/news/what-is-my-ip-address" rel="noopener noreferrer"&gt;Finding my IP from the command line&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
  </channel>
</rss>
