I'm trying to use psftp for a nightly sftp upload but I found out that it hangs. Does anyone have any experience with what may cause such hangs? The psftp can stay in this state for days at end. I tried adding -bc and -be to the start up, it already had -batch.

6 Answers
6

Open a command prompt (use runas /user:login@domain.com cmd if the task runs with credentials other than your own), then attempt to run the command that you have scheduled. If you are using the -batch parameter, remove it for troubleshooting purposes.

Does the command run properly?

I recently had a similar issue with pscp, it got stuck in a "Running" state because the account the scheduled task was configured to use had not connected to the specific server before and pscp generated the normal "The server's host key is not cached in the registry." prompt and was waiting for confirmation. Using the -batch parameter conceals this prompt. Once I had accepted the prompt once, it ran perfectly, even with -batch.

What is it connecting to? We have recently had some issues connecting to VMWare servers although other network traffic works fine. The transfers will stall out after 100-200K of data. We have also had issues in the past where a transfer would finish, but the server would not end the connection. Adding a quit statement to the batch scripts fixed that issue.

It's also possible that there's a server configuration or connectivity issue. You can test this by using the -v (verbose) flag on the transfer as noted in section 3.8.3.3 of the putty manual. Look for any error messages or warnings, and post them in your question.

If you transfering just only one (or few) files (usually that's true for backups) you can try using pscp instead of pftp - scp is older and simpler protocol, and it uses different SSH subsystem - so less points of failure.

If you are uploading using secure ftp behind a NAT firewall, or any other NAT device, you will be able to connect/authenticate, but won't be able to upload, list director contents, etc, without first modifying the firewall/NAT rules.

Sometimes servers try doing a reverse DNS lookup on your address, so if you're connecting from behind a firewall there will be a 30s+ delay in connecting. This often causes SFTP to timeout. We change the timeout to 60 or 120 when connecting to third parties, which almost always fixes the problem.