首先要確保兩台機子直接IP能夠互相ping通
然後使用SCP命令從第一台主機向第二台主機拷貝文件
scp src [email protected]:/home/linuxidc/mydisk/buffer_scp_file
ssh: connect to host 192.168.8.144 port 22: Connection refused
lost connection
檢查遠程主機沒有安裝sshd
linuxidc@linuxidc-VirtualBox:~/mydisk/buffer_scp_file$ sshd
程序“sshd”尚未安裝。 您可以使用以下命令安裝:
sudo apt-get install openssh-server
linuxidc@linuxidc-VirtualBox:~/mydisk/buffer_scp_file$ sudo apt-get install openssh-server
安裝完成之後開始傳輸文件,這裡我是傳輸文件夾,將文件夾下文件都傳輸過去,所以用了-r選項,不用該選項的話只能傳文件
[root@localhost /mydisk/eclispe_workspace/java]# scp -r src [email protected]:/home/linuxidc/mydisk/buffer_scp_file
[email protected]'s password:
logintest.txt 100% 977 1.0KB/s 00:00
ClassLoaderTest.java 100% 80 0.1KB/s 00:00
Test.java 100% 298 0.3KB/s 00:00
FileReadWriteByMemcached.java 100% 139 0.1KB/s 00:00
Client.java 100% 981 1.0KB/s 00:00
ObjectAnalyzer.java 100% 3738 3.7KB/s 00:00
Utils.java 100% 5703 5.6KB/s 00:00
TestQuick.java 100% 1481 1.5KB/s 00:00
TestAndPassportValidate.java 100% 1348 1.3KB/s 00:00
UtilsTest.java 100% 283 0.3KB/s 00:00
Test.java 100% 225 0.2KB/s 00:00
TransferRunnable.java 100% 614 0.6KB/s 00:00
Bank.java 100% 1041 1.0KB/s 00:00
UnSyncBankTest.java 100% 468 0.5KB/s 00:00
Test.java 100% 124 0.1KB/s 00:00
RSAUtils.java 100% 7691 7.5KB/s 00:00
RSATest.java 100% 1980 1.9KB/s 00:00
Base64Utils.java 100% 1924 1.9KB/s 00:00
Test.java 100% 2727 2.7KB/s 00:00
[root@localhost /mydisk/eclispe_workspace/java]#
到遠程主機對應的目錄去查看
linuxidc@linuxidc-VirtualBox:~/mydisk/buffer_scp_file$ ls
src
linuxidc@linuxidc-VirtualBox:~/mydisk/buffer_scp_file$ cd src/
linuxidc@linuxidc-VirtualBox:~/mydisk/buffer_scp_file/src$ ls
classloader jvm memcached rsa thread
demo logintest.txt reflect safedemo
linuxidc@linuxidc-VirtualBox:~/mydisk/buffer_scp_file/src$
以上是本機傳文件到遠程主機,下面再來試試從遠程主機拷貝文件到本機
[root@localhost /mydisk/eclispe_workspace/java]# scp [email protected]:/home/linuxidc/mydisk/buffer_scp_file/demo.txt /mydisk/
[email protected]'s password:
demo.txt 100% 14 0.0KB/s 00:00
[root@localhost /mydisk/eclispe_workspace/java]#
本機查看相應目錄
[root@localhost /mydisk]# ls
demo.txt Hadoop local_repo normandy_config software
eclispe_workspace learning_material maven_repo service
[root@localhost /mydisk]#
很實用,很簡單的命令!
Linux之cp/scp命令+scp命令詳解 http://www.linuxidc.com/Linux/2014-09/107127.htm
CentOS 不能使用scp命令 解決方法 http://www.linuxidc.com/Linux/2014-09/106569.htm
兩台Linux主機之間scp復制文件 http://www.linuxidc.com/Linux/2014-04/99979.htm
壓搾scp傳輸速度 http://www.linuxidc.com/Linux/2014-01/95498.htm
加速scp傳輸速度 http://www.linuxidc.com/Linux/2014-01/95497.htm
shell實現scp批量下發文件 http://www.linuxidc.com/Linux/2013-11/92783.htm