![sftpを使ってディレクトリとすべてのコンテンツを取得するには? [コピー]](https://linux33.com/image/43335/sftp%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%E3%81%A8%E3%81%99%E3%81%B9%E3%81%A6%E3%81%AE%E3%82%B3%E3%83%B3%E3%83%86%E3%83%B3%E3%83%84%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%EF%BC%9F%20%5B%E3%82%B3%E3%83%94%E3%83%BC%5D.png)
sftpでコマンドを使用しようとすると、get
通常のファイルではないというエラーが発生します。解決策はありますか?
答え1
sftp -r
ディレクトリを使用してホストに接続できますget
。接続時に使用を忘れてしまった場合でも-r
使用できますget -r
。
sftp -r me@somehost
または
sftp> get -r tmp/
Fetching /home/me/tmp/ to tmp
Retrieving /home/me/tmp
/home/me/new.orig.dmp 100% 417KB 416.8KB/s 00:00
/home/me/untangle.dmp 100% 398KB 398.3KB/s 00:00
/home/me/repos.orig.dmp 100% 415KB 415.2KB/s 00:00
/home/me/me-untangle.dmp 100% 32KB 32.4KB/s 00:00
sftp>
常に配信を保証するには、-r
それをエイリアスとして追加するか、類似の名前で追加してくださいsftp
。~/.bashrc
alias sftp="sftp -r"
~からman 1 sftp
-r Recursively copy entire directories when uploading and download‐
ing. Note that sftp does not follow symbolic links encountered
in the tree traversal.
.........
get [-Ppr] remote-path [local-path]
........
If either the -P or -p flag is specified, then full file permis‐
sions and access times are copied too.
If the -r flag is specified then directories will be copied
recursively. Note that sftp does not follow symbolic links when
performing recursive transfers.