   	{:noreply, s}
   end
 
+  defp sftp_channel(conn) do
+    case :ssh_sftp.start_channel(conn) do
+      {:ok, sftp} -> {:ok, sftp}
+      {:open_error, _, 'open failed', _} ->
+        sftp_channel(conn)
+    end
+  end
+
+  defp channel(conn) do
+    case :ssh_connection.session_channel(conn, :infinity) do
+      {:ok, ch} -> {:ok, ch}
+      {:open_error, _, 'open failed', _} ->
+        channel(conn)
+    end
+  end
+
 end
 
 defmodule Hypnotoad.Host.SSH.Channel.Sup do

    # Downloading #{file}
    """
    S.lock({Hypnotoad.Host.SSH.Connection, conn})
    {:ok, sftp_channel} = :ssh_sftp.start_channel(conn)
    {:ok, data} = :ssh_sftp.read_file(sftp_channel, file)
    :ssh_sftp.stop_channel(sftp_channel)
    S.unlock({Hypnotoad.Host.SSH.Connection, conn})

        # Uploading #{file} to #{new_path} (temporarily)
        """
        S.lock({Hypnotoad.Host.SSH.Connection, conn})
        {:ok, sftp_channel} = sftp_channel(conn)
        :ok = :ssh_sftp.write_file(sftp_channel, new_path, content)
        S.unlock({Hypnotoad.Host.SSH.Connection, conn})
        :gproc_ps.publish(:l, {Hypnotoad.Shell, ref}, """)
