   alias SSHKit.SCP
   
   def start, do: :ssh.start()
-
-  def connect(host, user, identity_file) do
-    with {:ok, identity} <- File.open(identity_file),
-      cb = ClientKeyAPI.with_options(identity: identity),
-      {:ok, conn} <- SSHKit.SSH.connect(host, [connect_timeout: 5000, key_cb: cb, user: user]) do
-      conn
-    else
+  
+  def connect(host, user, identity_file \\ nil) do
+    case SSHKit.SSH.connect(host, ssh_opts(user, identity_file)) do
+      {:ok, conn} -> conn
       {_, msg} -> raise "Error: #{msg}"
     end
   end

  defp parse_output(nil), do: ""
  defp parse_output(out) do
    String.trim_trailing(out)
  end    
end
  def run!(conn, cmd, working_directory) do
    case run(conn, build_cmd(cmd, working_directory)) do      
      {:ok, output, 0} -> {:ok, output}
      {:ok, output, status} -> raise format_error(cmd, output, status)
    end
  end

