Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default file transfer mode in SCP

Tags:

scp

I want to know what is the default mode used (ASCII or binary like FTP) while transferring files using SCP.

Is there any file mode concept in SCP ? How does it work ?

like image 441
user1109632 Avatar asked Jan 05 '12 06:01

user1109632


People also ask

Does SCP transfer in binary mode?

In essence, all files are transferred in "binary" mode, meaning that line endings are never changed.

What is SCP for file transfer?

SCP stands for Secure Copy Protocol. It is a tool that can be used to transfer files from a local host to a remote host, from a remote host to a local host, or between two remote hosts.

What is the default transfer mode for SFTP?

The FTP protocol defaults to the text/ascii mode, so one usually had to ensure that the mode was switched to the binary not to corrupt the transferred binary files. SFTP protocol also supports a text/ascii vs. binary mode distinction in its newer versions.


1 Answers

The file transfer modes in FTP are used to solve the problem of different operating systems having different line endings. The idea is that if a text file is transferred from a Unix machine to a Windows machine, the line endings must fixed, meaning that LF must be replaced by CR LF everywhere in the file. The reverse operation must be done when transferring the file in the other direction.

However, if you're transferring binary files, you want to leave the file as-is, because any LFs in the binary file are not actually line endings. Therefore, FTP introduced ASCII mode and Binary mode.

This is still a problematic solution, especially because the default mode is ASCII mode, so if you forgot to switch modes you might mangle your binary files and they won't work. The different modes are considered to cause more trouble than the problem they solve.

And so, SCP simply does not provide this feature, and always leaves the files as is. Fixing line endings is left to the user using tools like dos2unix and unix2dos.

In essence, all files are transferred in "binary" mode, meaning that line endings are never changed.

like image 79
cha0site Avatar answered Sep 20 '22 00:09

cha0site