Link to home
Create AccountLog in
Avatar of Neo
NeoFlag for Cyprus

asked on

sftp transfer

Uploading from a windows pc to a linux server via FTP removes carriage returns from ascii files.

When I upload via SFTP, FileZilla automatically sets the transfer type to 'binary' and the carriage returns are not removed.

What are the options to remove carriage returns before ascii files are uploaded?

Is there any secure protocol or software that removes carriage returns during upload?

thanks for your help
Avatar of skullnobrains
skullnobrains

run the transfer in ascii mode
this can be done in the filezilla gui, and made either the global default or specific to a preset connection in the connections manager

most ftp servers also have the option to force ascii mode but i have no idea how filezilla will react

if you switch to other protocols, none i know will do such conversions. but there are tools on linux to make the conversions and you can do them on the fly in some cases with a pipe. the tools are dos2unix and unix2dos. in debian and debian based distributions, they have been renamed/rewritten and the tool is named tofrodos
Avatar of Neo

ASKER

I know of ways to make the conversions (i.e remove the CR's), once the files are uploaded to the server. I would like however, to make sure that the CR's are removed before they are uploaded, either on my pc, or during upload.

When uploading via SFTP, FileZilla does not permit ascii mode.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Neo

ASKER

Are you sure your ascii files contained carriage returns before uploading?
Yes, I checked here on my Windows computer and on my Linux hosting and the \r\n endings were converted to just \n.  My hosting only allows SFTP file uploads.

When uploading via SFTP, FileZilla does not permit ascii mode.

filezilla does permit either mode, as any decent ftp client. your server may be set to only permit binary mode, but if that is the case, there should be an error in filezilla when you ask for ascii.

you'll find screenshots of mode transfer selection in filezilla and cuteftp here
https://manage.grabweb.net/knowledgebase.php?action=displayarticle&id=81

in filezilla, this may as well be set in the connection manager
sorry, i just saw you were using sftp.

forget it, ascii mode file transfer is specific to ftp (and ftps). it does not apply to sftp, or scp, or other protocols. using a different client will not change anything.
Avatar of Neo

ASKER

Dave: please use the following command and tell me the output

cat -ve file

the '^M$' at the end of each line indicates the CR's were not removed
the '$' at the end of each line indicated the CR's were removed.

This is probably what you meant with the  \r\n endings, however I want to be sure before I install the ftp client you suggested.

And also to wrap up: you are suggesting that coreftp removes CR's from ascii files with SFTP/binary, something that can be accomplished with FileZilla FTP/ascii, but not with FileZilla SFTP/binary. Why would this difference exist between coreftp SFTP and FileZilla SFTP? Is there anything I can change in FileZilla settings?


I would like to know your opinions about SFTP and FTPS encryption. Which type of encryption would you prefer?

The following quote is from 'http://manual.amstechdns.com/ftpes/'

To understand FTP and FTP over explicit TLS, you need to understand how FTP works. FTP consists of two parts, two channels. A control channel, which is used to authenticate a user and log them into the FTP system, and a data channel, which is used to actually transport files from one end to the other. A lot of times when you hear of FTPeS or any type of secure FTP based on the FTP standard, you get encryption but only for the control channel. That is your login information is encrypted, but when you actually send files, either uploading or downloading, the data channel is not encrypted and these pass over the wire in plain text.

Unfortunately, there is no way to differentiate the terminology here. FTPeS will always encrypt the control channel, assuming that the server supports it. But for the data channel, if FTPeS is used and if the FTP application supports it, then the data channel will be encrypted, but if the FTP application does not support it then the application will fall back to unencrypted data channel transmission.

FileZilla has the following two options:

explicit FTP over TLS
implicit FTP over TLS

Since they are listed as options does this mean that they are supported and that both the control and data channel will be encrypted?

The above quote is a bit vague, because how can FTPeS be used by the client and the client not be able to support it?

Finally, which should I prefer, explicit or implicit?
I don't need to do that.  I looked at my 'robots.txt' file in a hex dump on my Windows computer and on my Linux hosting in a hex dump and it is clear that the Windows file has '0d0a' and the Linux file only has '0a'.  It was uploaded with CoreFTP in SFTP because that is the only format my hosting company will allow.

CoreFTP has a list of file extensions that it transfers in ASCII mode but it doesn't give the option to select which mode it is using on the fly.  I can only assume that it uses that list to alter the line endings itself since the help file says it transfers everything by default in binary mode.

I don't have any sites that use FTPS so I have never to my knowledge used it.  Note that SFTP uses SSH encryption and FTPS uses TLS.  They are not interchangeable, they are completely different protocols.

I have both CoreFTP and Filezilla installed on this computer.  They're both free.  CoreFTP does what I need and I haven't had to mess with the settings so that's the one I use.
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account