问题
Please, tell me how SCP work. Can anybody explain(or show) SCP file transfer to me (something look like picture, flow or reference). & one more question. What're difference between SCP and SFTP file transfer ?
Thank you anyone for assist. And sorry about my language.
回答1:
The SCP client connects to the SSH server and executes scp
command there. In most cases, the remote scp
would be the OpenSSH scp
command. That means, if you use the OpenSSH scp
command as a client, the local scp
(as a client) actually talks to the same program on the server. The remote scp
is executed with undocumented -t
(to) or -f
(from) flags. This way, the scp
program recognizes that it serves as a server.
Once the remote scp
is running, it talks with the local SCP client (the scp
or another implementation) using a simple protocol.
An SCP command is one-letter followed by some arguments and new-line.
An SCP response is one byte, with 0x00
= ok, 0x01
= error, 0x02
= fatal error (though the OpenSSH scp
actually never responds with 0x02
). The error code is followed by an error message (terminated with a new-line).
It's always the source side that feeds the commands. The target side consumes them. I.e. when downloading, the server feeds the commands and the client consumes them. When uploading, the client feeds the commands and the server consumes them.
Commands are:
E
- exitT
- sets timestamps for the upcoming fileC
- file transferD
- directory
See also Explanation for SCP protocol implementation in JSch library.
来源:https://stackoverflow.com/questions/37558853/how-is-scp-secure-copy-protocol-file-transfer-working