Division By Zero

ゼロで割る

scpとsftpの違いについて少し調べてみた際のメモ

scpをずっと使っていて、ここ数年はsftpも使うようになったが、今一つsftpが何だかわかっていないことに気付いたので少し検索。

ここがわかりやすい。

リンク先の図を見るとわかるように、scpの場合、ローカル、リモートの両方にscpプログラムが必要になる。CentOSなら、openssh-clientsが双方に必要だ。ローカルはともかく、リモート側に必要なのは直観的にわかりにくい。また、この仕組み上、ワイルドカード等で互換性の問題があり、sftpの開発動機の一つにはなっているようだ。

SFTP attempts to be more platform-independent than SCP; for instance, with SCP, the expansion of wildcards specified by the client is up to the server, whereas SFTP's design avoids this problem. While SCP is most frequently implemented on Unix platforms, SFTP servers are commonly available on most platforms.

http://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol

sftpの場合、ローカルにはopenssh-clients、リモートにはopenssh-serverがあればよい。つまりssh接続できるリモートホストに対して、必ずscpできるわけではないが、sftpは可能なはず。PCからもWinSCP等でscpできなくてもsftpはできるはず。

WinSCPなどで、WindowsからUTF8ベースのLinuxにファイル転送する際の日本語ファイル名の文字化け問題も、WinSCPで「Protocol/File protocol」で「SFTP」を選び、「Environment/Server environment/UTF-8 encoding for filenames」を「On」にすると解消。問題も解決したので今日は終了!