transfermode types in sftp
19,485
SFTP
works on top of ssh
and does not have equivalent for FTP
transfer mode. In other words, SFTP
transfer is always binary, byte to byte exact.
You should not confuse SFTP
with FTPS
though. FTPS
is much like old FTP
, but over SSL
, and is supported by some servers. Because it is still old FTP wrapped in SSL, it does support notion of transfer mode (ascii or binary). However, FTPS servers are very rare in the wild, and I think it is very difficult to actually encounter one.
Author by
cacert
Updated on June 04, 2022Comments
-
cacert over 1 year
Is there any difference between ftp and sftp tranfser types in terms of transfer modes (binary, ASCII)? In sftp transfer do we still have binary and ASCII transfer option or it has its default mode whether we choose or not.
-
cacert over 10 yearsthank you for your answer. Do you have any idea how can i send file from unix to windows system using sftp, as far as i understand there will be a EOL problem in this case.
-
mvp over 10 yearsWinSCP is an excellent utility to transfer files between Windows and Linux (it only needs
ssh
to work). Line endings will be preserved exactly - and this is a good thing (otherwise it may corrupt executables or images). If you don't like CRLF on Linux, use utilitiesdos2unix
orfromdos
in Linux shell to convertCRLF
toLF
only. -
cacert over 10 yearsactually I have a custom java application for sending files. This application runs on unix and send/receives files from unix and windows. in case we were using ftp everything was fine. we were just stting correct mode and done. However in case sftp EOL problems arised.
-
mvp over 10 yearsIf used properly, Windows programs and editors can work fine with files using
LF
only. And the opposite is true: except for few cases, Linux scripts will work using CRLF endings. However, this has one secret: in scripts (bash
,perl
, etc) use some non-important parameter after first space in shebang line to make it ignore CRLF issues. For example, in Perl, using!#/usr/bin/perl -w<CRLF>
will work fine, but!#/usr/bin/perl<CRLF>
will fail. You can also use something like!#/usr/bin/env perl<CRLF>
-
cacert over 10 yearsi was using edtftpj api's sshclient. may be there is a way to do it in that api too programmatically.
-
Eugene Mayevski 'Callback over 10 yearsFYI: SFTP protocol version 4 and later has ASCII mode.