首先,以确保直接两个机器IP可以在每个ping通过
然后使用SCP命令从第一台主机向第二台主机复制文件
scp src chiwei@192.168.8.144:/home/chiwei/mydisk/buffer_scp_file
ssh: connect to host 192.168.8.144 port 22: Connection refused
lost connection
检查远程主机没有安装sshd
chiwei@chiwei-VirtualBox:~/mydisk/buffer_scp_file$ sshd
程序“sshd”尚未安装。 您能够使用下面命令安装:
sudo apt-get install openssh-server
chiwei@chiwei-VirtualBox:~/mydisk/buffer_scp_file$ sudo apt-get install openssh-server
安装完毕之后開始传输文件。这里我是传输目录,将目录下文件都传输过去,所以用了-r选项,不用该选项的话仅仅能传文件
[root@localhost /mydisk/eclispe_workspace/java]# scp -r src chiwei@192.168.8.144:/home/chiwei/mydisk/buffer_scp_file
chiwei@192.168.8.144'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]#
到远程主机相应的文件夹去查看
chiwei@chiwei-VirtualBox:~/mydisk/buffer_scp_file$ ls
src
chiwei@chiwei-VirtualBox:~/mydisk/buffer_scp_file$ cd src/
chiwei@chiwei-VirtualBox:~/mydisk/buffer_scp_file/src$ ls
classloader jvm memcached rsa thread
demo logintest.txt reflect safedemo
chiwei@chiwei-VirtualBox:~/mydisk/buffer_scp_file/src$
[root@localhost /mydisk/eclispe_workspace/java]# scp chiwei@192.168.8.144:/home/chiwei/mydisk/buffer_scp_file/demo.txt /mydisk/
chiwei@192.168.8.144's password:
demo.txt 100% 14 0.0KB/s 00:00
[root@localhost /mydisk/eclispe_workspace/java]#
本机查看对应文件夹
[root@localhost /mydisk]# ls
<span style="color:#ff0000;"><strong>demo.txt</strong></span> hadoop local_repo normandy_config software
eclispe_workspace learning_material maven_repo service
[root@localhost /mydisk]#
很有帮助,非常easy该命令。