Filezilla SFTP “Connection closed by server with exitcode 141″

Just a quick note, I was trying to connect to a remote server with SFTP using Filezilla. I use SSH key for authentication. But Filezilla threw me this error : “Connection closed by server with exitcode 141″.

I tried using the commandline sftp with -v , it said:

debug1: Sending subsystem: sftp
debug1: client_input_channel_req: channel 0 rtype exit-signal reply 0
debug1: client_input_channel_req: channel 0 rtype reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
Transferred: sent 3440, received 2568 bytes, in 0.1 seconds
Bytes per second: sent 50284.4, received 37537.9
debug1: Exit status -1

I found that it was my shell configuration which was causing the problem. I have some customized settings, every time I login, it beeps “MY_VARIABLE:  Undefined variable". The message causes SFTP to fail.