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.

Share:
19,485
cacert
Author by

cacert

Updated on June 04, 2022

Comments

  • cacert
    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
    cacert over 10 years
    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.
  • mvp
    mvp over 10 years
    WinSCP 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.
  • cacert
    cacert over 10 years
    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.
  • mvp
    mvp over 10 years
    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<CRLF> will work fine, but !#/usr/bin/perl<CRLF> will fail. You can also use something like !#/usr/bin/env perl<CRLF>
  • cacert
    cacert over 10 years
    i was using edtftpj api's sshclient. may be there is a way to do it in that api too programmatically.
  • Eugene Mayevski 'Callback
    Eugene Mayevski 'Callback over 10 years
    FYI: SFTP protocol version 4 and later has ASCII mode.