復制本地文件到遠程
scp命令——拷貝樹莓派數據到本地
場景:Mac下ssh登陸樹莓派,樹莓派上的文件拷貝到本地。
實現方式:scp命令并且mac上開啟ssh服務
語法規則
scp [raspberry pi file path] macname@192.168.1.101:[local file path]
會詢問你是否遠程鏈接mac
選擇 yes
會提示你輸入mac密碼
Passord:
輸入mac密碼
實例
```
pi@xxxxxx:/usr/share/nginx/html/yunchuang.zhijia.com$scp php_mysql/? macname@192.168.1.101:/home/xxx/
The authenticity of host'192.168.1.101 (192.168.1.101)'can't be established.
ECDSA key fingerprint is 2f:5g:78:03:9e:3a:52:c5:70:ea:77:a4:cf:23:3d:ba.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.101' (ECDSA) to the list of known hosts.
Password:
php_mysql: not a regular file
pi@xxxxxx:/usr/share/nginx/html/yunchuang.zhijia.com$ scp php_mysql/?
macname@192.168.1.101:~/home/xxx/
Password:
php_mysql: not a regular file
pi@xxxxxx:/usr/share/nginx/html/yunchuang.zhijia.com$
```
注意這句php_mysql: not a regular file不是一個常規文件,不帶參數不能直接copy整個目錄。
```
pi@xxxxxx:/usr/share/nginx/html/yunchuang.zhijia.com$scp php_mysql/create_db.php? macname@192.168.1.101:~/home/xxx/
Password:create_db.php
100%? ? ? 338? ? ? 0.3KB/s? ? ? 00:00
```
好了,一次copy一個文件。
scp拷貝一個文件夾下面所有(包含文件夾和文件)
sudo scp -r? xxxxxx@192.168.1.102:/Users/xxxxxx/Downloads/nginx-rtmp-module .
復制遠程文件到本地
localhost:~ xxx$ scp pi@192.168.1.100:~/workspace/NASA/NASA-master/car.py .
pi@192.168.1.100's password:
car.py? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 100% 3545? 313.6KB/s? 00:00
localhost:~ wangliang$