3

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.

Nayuki
  • 17,911
  • 6
  • 53
  • 80
cacert
  • 2,677
  • 10
  • 33
  • 56

1 Answers1

8

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.

mvp
  • 111,019
  • 13
  • 122
  • 148
  • 1
    thank 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. – cacert Feb 22 '13 at 09:12
  • 1
    [WinSCP](http://winscp.net) 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 utilities `dos2unix` or `fromdos` in Linux shell to convert `CRLF` to `LF` only. – mvp Feb 22 '13 at 09:16
  • actually 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. – cacert Feb 22 '13 at 09:25
  • If 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` will work fine, but `!#/usr/bin/perl` will fail. You can also use something like `!#/usr/bin/env perl` – mvp Feb 22 '13 at 09:32
  • i was using edtftpj api's sshclient. may be there is a way to do it in that api too programmatically. – cacert Feb 22 '13 at 09:56
  • 2
    FYI: SFTP protocol version 4 and later has ASCII mode. – Eugene Mayevski 'Callback Feb 22 '13 at 15:33