Invalid Handle
Hi,
I am getting an error of 'Invalid Handle' when trying to transfer a file to an sFTP using the WinSCP client directly, or through an SSIS package.
Through the client:
SSIS Log:
(Server names etc removed)
I am getting an error of 'Invalid Handle' when trying to transfer a file to an sFTP using the WinSCP client directly, or through an SSIS package.
Through the client:

SSIS Log:
. 2015-04-23 09:28:57.272 -------------------------------------------------------------------------- . 2015-04-23 09:28:57.272 WinSCP Version 5.5.4 (Build 4433) (OS 6.1.7601 Service Pack 1 - Windows Server 2008 R2 Standard) . 2015-04-23 09:28:57.272 Configuration: HKEY_CURRENT_USER\Software\Martin Prikryl\WinSCP 2\ . 2015-04-23 09:28:57.272 Local account: CM-CORP-TH\gareth.sweet . 2015-04-23 09:28:57.272 Working directory: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE . 2015-04-23 09:28:57.272 Process ID: 2508 . 2015-04-23 09:28:57.273 Command-line: "C:\Program Files (x86)\WinSCP\WinSCP.exe" /console=554 /consoleinstance=_3756_413 "/log=D:\Packages\UploadLog.log" . 2015-04-23 09:28:57.273 Time zone: Current: GMT+1, Standard: GMT+0 (GMT Standard Time), DST: GMT+1 (GMT Daylight Time), DST Start: 29/03/2015, DST End: 25/10/2015 . 2015-04-23 09:28:57.273 Login time: 23 April 2015 09:28:57 . 2015-04-23 09:28:57.273 -------------------------------------------------------------------------- . 2015-04-23 09:28:57.273 Script: Retrospectively logging previous script records: > 2015-04-23 09:28:57.273 Script: option batch on < 2015-04-23 09:28:57.273 Script: batch on > 2015-04-23 09:28:57.273 Script: open xxx . 2015-04-23 09:28:57.273 -------------------------------------------------------------------------- . 2015-04-23 09:28:57.273 Session name: xxx@xxx (Modified site) . 2015-04-23 09:28:57.273 Host name: xxx . 2015-04-23 09:28:57.273 User name: xxx (Password: Yes, Key file: No) . 2015-04-23 09:28:57.273 Tunnel: No . 2015-04-23 09:28:57.273 Transfer Protocol: SFTP . 2015-04-23 09:28:57.273 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec . 2015-04-23 09:28:57.273 Proxy: none . 2015-04-23 09:28:57.273 Send buffer: 262144 . 2015-04-23 09:28:57.273 SSH protocol version: 2; Compression: No . 2015-04-23 09:28:57.273 Bypass authentication: No . 2015-04-23 09:28:57.273 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No . 2015-04-23 09:28:57.273 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No . 2015-04-23 09:28:57.273 SSH Bugs: A,A,A,A,A,A,A,A,A,A . 2015-04-23 09:28:57.273 Simple channel: Yes . 2015-04-23 09:28:57.273 Return code variable: Autodetect; Lookup user groups: A . 2015-04-23 09:28:57.273 Shell: default . 2015-04-23 09:28:57.273 EOL: 0, UTF: 2 . 2015-04-23 09:28:57.273 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes . 2015-04-23 09:28:57.273 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No . 2015-04-23 09:28:57.273 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes . 2015-04-23 09:28:57.273 Cache directory changes: Yes, Permanent: Yes . 2015-04-23 09:28:57.273 DST mode: 1; Timezone offset: 0h 0m . 2015-04-23 09:28:57.273 -------------------------------------------------------------------------- . 2015-04-23 09:28:57.274 Looking up host "xxx" . 2015-04-23 09:28:57.274 Connecting to xxx . 2015-04-23 09:28:57.278 Server version: SSH-2.0-1.82 sshlib: sshlibSrSshServer 1.00 . 2015-04-23 09:28:57.278 Using SSH protocol version 2 . 2015-04-23 09:28:57.278 We claim version: SSH-2.0-WinSCP_release_5.5.4 . 2015-04-23 09:28:57.279 Doing Diffie-Hellman group exchange . 2015-04-23 09:28:57.476 Doing Diffie-Hellman key exchange with hash SHA-1 . 2015-04-23 09:28:57.788 Verifying host key xxx . 2015-04-23 09:28:57.789 Host key matches cached key . 2015-04-23 09:28:57.789 Host key fingerprint is: . 2015-04-23 09:28:57.789 xxx . 2015-04-23 09:28:57.789 Initialised AES-256 CBC client->server encryption . 2015-04-23 09:28:57.789 Initialised HMAC-SHA1 client->server MAC algorithm . 2015-04-23 09:28:57.789 Initialised AES-256 CBC server->client encryption . 2015-04-23 09:28:57.789 Initialised HMAC-SHA1 server->client MAC algorithm ! 2015-04-23 09:28:57.992 Using username "sql_dev_test". . 2015-04-23 09:28:57.993 Prompt (7, SSH password, , &Password: ) . 2015-04-23 09:28:57.993 Using stored password. . 2015-04-23 09:28:57.993 Sent password . 2015-04-23 09:28:58.054 Access granted . 2015-04-23 09:28:58.054 Opening session as main channel . 2015-04-23 09:28:58.055 Opened main channel . 2015-04-23 09:28:58.258 Started a shell/command . 2015-04-23 09:28:58.258 -------------------------------------------------------------------------- . 2015-04-23 09:28:58.258 Using SFTP protocol. . 2015-04-23 09:28:58.258 Doing startup conversation with host. > 2015-04-23 09:28:58.258 Type: SSH_FXP_INIT, Size: 5, Number: -1 < 2015-04-23 09:28:58.260 Type: SSH_FXP_VERSION, Size: 5, Number: -1 . 2015-04-23 09:28:58.260 SFTP version 3 negotiated. . 2015-04-23 09:28:58.260 We believe the server has signed timestamps bug . 2015-04-23 09:28:58.260 We will use UTF-8 strings when appropriate . 2015-04-23 09:28:58.260 Getting current directory name. . 2015-04-23 09:28:58.260 Getting real path for '.' > 2015-04-23 09:28:58.260 Type: SSH_FXP_REALPATH, Size: 10, Number: 16 < 2015-04-23 09:28:58.262 Type: SSH_FXP_NAME, Size: 51, Number: 16 . 2015-04-23 09:28:58.262 Real path is '/' . 2015-04-23 09:28:58.262 Startup conversation with host finished. < 2015-04-23 09:28:58.262 Script: Active session: [1] xxx@xxx > 2015-04-23 09:28:58.262 Script: cd Gareth . 2015-04-23 09:28:58.262 Cached directory change via "Gareth" to "/Gareth". . 2015-04-23 09:28:58.262 Getting current directory name. < 2015-04-23 09:28:58.262 Script: /Gareth > 2015-04-23 09:28:58.263 Script: option transfer binary < 2015-04-23 09:28:58.263 Script: transfer binary > 2015-04-23 09:28:58.263 Script: option confirm off < 2015-04-23 09:28:58.263 Script: confirm off > 2015-04-23 09:28:58.263 Script: put -delete C:\Users\gareth.sweet\123.jpg . 2015-04-23 09:28:58.263 Copying 1 files/directories to remote directory "/Gareth" . 2015-04-23 09:28:58.263 PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask: . 2015-04-23 09:28:58.263 TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM: . 2015-04-23 09:28:58.263 AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml . 2015-04-23 09:28:58.263 File: 'C:\Users\gareth.sweet\123.jpg' [2015-04-23T08:27:52.899Z] [880471] . 2015-04-23 09:28:58.263 Copying "C:\Users\gareth.sweet\123.jpg" to remote directory started. . 2015-04-23 09:28:58.263 Binary transfer mode selected. . 2015-04-23 09:28:58.263 Checking existence of file. > 2015-04-23 09:28:58.263 Type: SSH_FXP_LSTAT, Size: 24, Number: 263 < 2015-04-23 09:28:58.265 Type: SSH_FXP_STATUS, Size: 30, Number: 263 < 2015-04-23 09:28:58.265 Status code: 2 . 2015-04-23 09:28:58.265 Checking existence of partially transfered file. > 2015-04-23 09:28:58.265 Type: SSH_FXP_LSTAT, Size: 33, Number: 519 < 2015-04-23 09:28:58.267 Type: SSH_FXP_STATUS, Size: 30, Number: 519 < 2015-04-23 09:28:58.267 Status code: 2 . 2015-04-23 09:28:58.267 Opening remote file. > 2015-04-23 09:28:58.267 Type: SSH_FXP_OPEN, Size: 49, Number: 771 < 2015-04-23 09:28:58.278 Type: SSH_FXP_STATUS, Size: 32, Number: 771 < 2015-04-23 09:28:58.279 Status code: 9, Message: 771, Server: Invalid handle., Language: > 2015-04-23 09:28:58.279 Type: SSH_FXP_LSTAT, Size: 33, Number: 1031 < 2015-04-23 09:28:58.281 Type: SSH_FXP_STATUS, Size: 30, Number: 1031 < 2015-04-23 09:28:58.281 Status code: 2, Message: 1031, Server: No such file., Language: * 2015-04-23 09:28:58.281 (ETerminal) Invalid handle. * 2015-04-23 09:28:58.281 Error code: 9 * 2015-04-23 09:28:58.281 Error message from server: Invalid handle. . 2015-04-23 09:28:58.281 Asking user: . 2015-04-23 09:28:58.281 Cannot create remote file '/Gareth/123.jpg.filepart'. ("Invalid handle. . 2015-04-23 09:28:58.281 Error code: 9 . 2015-04-23 09:28:58.281 Error message from server: Invalid handle.") < 2015-04-23 09:28:58.281 Script: Cannot create remote file '/Gareth/123.jpg.filepart'. < 2015-04-23 09:28:58.282 Script: Invalid handle. < 2015-04-23 09:28:58.282 Error code: 9 < 2015-04-23 09:28:58.282 Error message from server: Invalid handle. * 2015-04-23 09:28:58.282 (EScpSkipFile) Cannot create remote file '/Gareth/123.jpg.filepart'. * 2015-04-23 09:28:58.282 Invalid handle. * 2015-04-23 09:28:58.282 Error code: 9 * 2015-04-23 09:28:58.282 Error message from server: Invalid handle. . 2015-04-23 09:28:58.282 Script: Failed > 2015-04-23 09:28:58.283 Script: close . 2015-04-23 09:28:58.283 Closing connection. . 2015-04-23 09:28:58.283 Sending special code: 12 . 2015-04-23 09:28:58.283 Sent EOF message