I have a simple text file that I am uploading from a windows platform to a Unix server using SFTP (Client: FireFTP). I have noticed that when uploading using SFTP rather than plain FTP, the file is forced to upload in "Binary" mode rather than in "ASCII".
Anyone aware of the reasoning behind enforcing the transfer method? Normally this would not matter but I am parsing this file (char by char) on the server and the hanging ^M that is left on the file when uploaded in "Binary" causes an issue with my parser.
Yes, I am changing the parser to handle this but, I am mainly interested in why SFTP forces the upload to occur in "binary" rather than "ASCII?
Is it a security vulnerability that I am not understanding perhaps?
Is this a matter of what SFTP protocol version the client is using (In this case FireFTP)?
EDIT:
If "ASCII" is no longer an option with modern SFTP, is it simply "accepted" that when transferring a file from Windows -> Unix that you will have the additional CR (^M) leftover throughout the file on the Unix server where previously contained the standard Windows(CRLF)?
Thanks for the guidance
FTP != SFTP. This is most important thing you should note.
And ASCII mode is just a ancient nonsense. There is no such thing in quite modern SFTP, which just transfer bytes as they are (there is no reason to do it other way).
The Firezilla wiki has a page on technical specifications. The most widely implemented version of the SFTP spec is version 3 draft 2. Notably, the Openssh SFTP client and server implement that version of the spec.
Version 3 of the SFTP protocol doesn't have a feature equivalent to FTP's ASCII transfer mode. It always transfers files verbatim.
Later versions of the SFTP protocol support transfer modes that convert line terminator characters. Hypothetically, you could find a client and server that supports the feature.
I don't know FireFTP's capabilities. But the OpenSSH SFTP server doesn't support an ASCII-like transfer mode.
There are various ways of dealing with the issue. There are programs to convert from one format to another. Some programs that read text files will tolerate line terminators in either format.
SFTP protocol has several versions (1-6) with version 3 being the most popular. ASCII mode has been added in version 4 of the protocol.
In our SecureBlackbox product we emulate ASCII mode if connection has been negotiated with version 3 or lower of the protocol, but such emulation requires that you know the OS (or line ending) of the remote server. Also ASCII mode makes it harder to implement so-called pipelining of SFTP requests, the feature, that makes SFTP transfer much faster.