title: No connection as non root using Net::SFTP::Foreign
body: <p>I am trying to use a perl script to transfer files from one machine to another within a cron job. However for security reasons the cron job has to run as a unprivileged user. Now if I try to establish a connection using this unpriviliged user, <code>Net::SFTP::Foreign</code> always refuses to connect. Here is the part of the script I am having trouble with:</p>
  
  <pre><code>my $host = "hostname";
  my %args = (
      user =&gt; "username",
      password =&gt; "password",                                                                                                                                                                                       
      port =&gt; '12345'
  );
  my $sftp_connection = Net::SFTP::Foreign-&gt;new($host, %args);
  if( $sftp_connection-&gt;error ) {
      log_message( "E", "Error " . $sftp_connection-&gt;status() . " connecting to " . $host );
      die;
  }
  log_message( "A", "Connected" );
  </code></pre>
  
  <p>I cannot give a full example, as this would require username and password.</p>
  
  <p>If I execute this script as root, everything works fine, however if I try to use another user, the connection always fails.</p>
  
  <p>Is there a way to get some more diagnostic information? I think there was a way to get more output from the actual sftp process, but I cannot look it up right now as cpan currently does not work from here.</p>
  
  <p>I previously also tried using <code>Net::SFTP</code> instead of <code>Net::SFTP</code>, but the error handling at later parts did not work correctly, so switching to <code>Net::SFTP</code> does not seem a viable option right now.</p>