$sftp = Net::SFTP::Foreign->new("$user\@$host"); $sftp->error and die "unable to connect to remote host: " . $sftp->error;