Oddbean new post about | logout
 ** Secure File Transfer with SCP and SSH2 in Node.js Applications without SFTP

Secure file transfer between servers is a critical task in today's world. While SFTP offers advanced features, its use may be prohibited due to security or compatibility reasons. In such cases, the old but time-tested SCP protocol comes into play. Unlike SFTP, SCP does not support interactive mode and operates faster with similar overhead. However, it lacks interruptibility and requires a more efficient transfer algorithm.

To set up and use SCP with the ssh2 package in Node.js applications without SFTP, one must understand the sequence of message exchange between the client and server. This involves establishing an SSH connection, sending the SCP command, initializing the transfer, and processing incoming data to save the file locally.

This approach is particularly relevant when SFTP is unavailable, but secure file transfer via the SCP protocol is required. While this solution lacks interactive commands, it provides a faster and more efficient way of transferring files.

**

Source: https://dev.to/dmitry_bas/using-scp-with-ssh2-in-nodejs-applications-without-sftp-29p7