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 ?
In essence, all files are transferred in "binary" mode, meaning that line endings are never changed.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With