title: Communication protocol using netcat
body: <p>I need to create a way to communicate commands and transfer files from a host server to a development board.</p>
  
  <ul>
  <li>The only access to the board is via the host server (wired Ethernet connection).</li>
  <li>Both the host server and the board are running Linux.</li>
  <li>I have the ability to change the Linux environment on the board.</li>
  <li>I DO NOT have the ability to change the host server environment.</li>
  <li>I DO NOT know which users need to connect to the board.</li>
  <li>The connection between the host server and the board does not need to be secure.</li>
  </ul>
  
  <p>Right now, I'm using netcat for my needs but have run into reliability issues - Could someone point me to some tools that are better suited to my needs and perhaps higher performance, please?</p>
  
  <p>My current solution:</p>
  
  <p>A script is constantly running on the board:</p>
  
  <pre><code>while [ 1 ] ; do
      # Start a netcat server, awaiting a file.
      nc -l -p 1357 &gt; file.bin
  
      # Acknowledge receipt of file.
      status=fail
      while [ ${status} -ne 0 ] ; do
          status=$(echo 0 | nc &lt;host_ip&gt; 2468 2&gt;&amp;1)
      done
  
      # Wait for a command.
      nc -l -p 1357 -e /bin/sh
  
      # Acknowledge receipt of command.
      status=fail
      while [ ${status} -ne 0 ] ; do
          status=$(echo 0 | nc &lt;host ip&gt; 2468 2&gt;&amp;1)
      done
  done
  </code></pre>
  
  <p>The only way users have access to the board is through a script on the server:</p>
  
  <pre><code># Send over a file.
  cat some_file.bin | /bin/nc -w 10
  
  # Wait for acknowledge.
  if [ $( nc -l 2468 ) -ne 0 ] ; then
      exit # Fail
  fi
  
  # Send a command.
  echo "&lt;some_command&gt;" | nc -w 10 &lt;board ip&gt; 1357
  
  # Wait for acknowledge.
  if [ $( nc -l 2468 ) -ne 0 ] ; then
      exit # Fail
  fi
  </code></pre>
  
  <p>The reason I'm using netcat right now is that I don't know of any way to use SSH or SCP without a password given that:</p>
  
  <ul>
  <li>I can't generate an SSH key for everyone that needs access to the board, especially since I don't know who will be using it.</li>
  <li>I can't install sshpass or expect since I don't have control of the server.</li>
  </ul>
  
  <p>Please help,
  Thanks.</p>