--- title: 【軟體】檔案傳輸工具 sftp tags: TTennis Pickup Robot disqus: hackmd --- <h1 style="text-align: center; color: orange;"> 🛠️ 【軟體】網路、通訊 🛠️ </h1> <h2 style="text-align: center; color: skyblue;">檔案傳輸工具 sftp</h2> <center> 電腦在同個網域下, sftp 是個互傳檔案的好工具。 </center> <h3><font color="magenza"> 從 Remote 傳輸檔案到 Local </font></h3> <h4><font color="yellow"> sftp 版本 </font></h4> 1. 在 Host A 上打開終端機,使用 `sftp` 連線到 Host B: ```bash sftp user@remote ``` 2. 進入 Host B 的檔案所在目錄: ```bash cd [remote-path] ``` 3. 設定 Host A 的參考位置: ```bash lcd [local-path] ``` 4. 使用 `get` 下載(或 `put` 上傳): ```bash ## 單一檔案 get [filename] ## 資料夾 get -r * ``` 5. 結束 `sftp` 連線: ```bash exit ``` <h4><font color="yellow"> scp 版本 </font></h4> 1. 從 remote 端傳輸檔案到 local: ```bash ## 單一檔案 scp user@remote:[remote-path] [local-path] ## 資料夾 scp -r user@remote:[remote-path] [local-path] ``` 2. 推送 local 端檔案到 remote 端: ```bash ## 單一檔案 scp [local-path] user@remote:[remote-path] ## 資料夾 scp -r [local-path] user@remote:[remote-path] ```