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.
I assume you are using scheduled tasks to run this nightly?
Open a command prompt (use
runas /user:firstname.lastname@example.org 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 18.104.22.168 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.
Here is wikipedia links to this protocols if you are interesting:
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.
Check http://www.lancerobinson.net/archive/2005/08/23/50912.aspx for more info.