sftp
網路
用法
sftp [-P <port>] <user>@<host>架在 ssh 連線之上的互動式傳輸工具;埠選項是大寫 `-P` 而不是 ssh 的 `-p`,而且它不能執行遠端 shell 命令,只認自己的 put、get、ls。
常用選項
| 選項 | 含義 |
|---|---|
| -P 2222 | Port, capital P. ssh uses lowercase -p for the same thing. |
| -i <key> | Use a specific private key. |
| -r | Recursive, for put -r and get -r on directories. |
| -b <batchfile> | Run a list of commands without a prompt, for scripts. |
| put / get / ls / lcd | Its own commands inside the session; lcd changes the local directory. |
範例
sftp -P 2222 deploy@example.comOpen an interactive transfer session.
sftp deploy@example.com:/var/log/app.log .Fetch one file without entering the prompt.
連不上的時候,這些能把範圍縮小——是名稱解析不了、沒有路由,還是連接埠被擋。
怎麼看
- 方括號 [ ] 表示這部分可以不寫。
- 省略號 … 表示可以寫多個。
- 選項區分大小寫——有些命令裡 -r 和 -R 不是一回事。
常見問題
Q. sftp 是做什麼的?
架在 ssh 連線之上的互動式傳輸工具;埠選項是大寫 `-P` 而不是 ssh 的 `-p`,而且它不能執行遠端 shell 命令,只認自己的 put、get、ls。
Q. 怎麼寫?
sftp [-P <port>] <user>@<host> —— 方括號表示可以省略的部分。
Q. 值得記的選項有幾個?
這裡列了 5 個,完整列表在 man sftp。這條命令屬於網路。
相關命令
man 手冊: man sftp