Naive SCP module in Elixir
I have never used Elixir in my life until seeing this question, so my feedback is very limited and I probably shouldn't be putting an answer on here. However, there are a few ways it could be simplified:


the module lstat(path, opts \\ []) reads information about a path, returns a FileStat struct which has a type: field which can be type: :device | :directory | :regular | :other | :symlink; this could be used to determine what the path is (and whether to use -r), and if there is an error it means that the path does not exist (thus adding in the error handling)
in the case {resp, exit_code} -&gt; instead of checking the error message contents via String.contains?, do the switching based on exit code and then return the appropriate error messages.
in the case {resp, exit_code} -&gt;, I'd add a few extra error-handlers for statuses (for example directory not found on destination, invalid credentials, etc.)
for the inputs (user and ip address), a regex could be used to ensure sanity (the ip address looks like an ip, the username is not blank, etc.)
the case true -&gt; {:error, :errunkown, exit_code} could be replaced with _ -&gt; {:error, :errunkown, exit_code} as _ appears to be a fall through (I'm unsure about this)