復(fù)制本地文件到遠(yuǎn)程
scp命令——拷貝樹(shù)莓派數(shù)據(jù)到本地
場(chǎng)景:Mac下ssh登陸樹(shù)莓派,樹(shù)莓派上的文件拷貝到本地。
實(shí)現(xiàn)方式:scp命令并且mac上開(kāi)啟ssh服務(wù)
語(yǔ)法規(guī)則
scp [raspberry pi file path] macname@192.168.1.101:[local file path]
會(huì)詢問(wèn)你是否遠(yuǎn)程鏈接mac
選擇 yes
會(huì)提示你輸入mac密碼
Passord:
輸入mac密碼
實(shí)例
```
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不是一個(gè)常規(guī)文件,不帶參數(shù)不能直接copy整個(gè)目錄。
```
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一個(gè)文件。
scp拷貝一個(gè)文件夾下面所有(包含文件夾和文件)
sudo scp -r? xxxxxx@192.168.1.102:/Users/xxxxxx/Downloads/nginx-rtmp-module .
復(fù)制遠(yuǎn)程文件到本地
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$