     # Downloading #{file}
     """
     S.lock({Hypnotoad.Host.SSH.Connection, conn})
-    {:ok, sftp_channel} = :ssh_sftp.start_channel(conn)
+    {:ok, sftp_channel} = sftp_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}
    """
    S.lock({Hypnotoad.Host.SSH.Connection, conn})
    {:ok, sftp_channel} = :ssh_sftp.start_channel(conn)
    case :ssh_sftp.write_file(sftp_channel, file, content) do
      :ok ->
        :ssh_sftp.stop_channel(sftp_channel)

  	{: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
