首先要确保两台机子直接IP能够互相ping通
然后使用SCP命令从第一台主机向第二台主机拷贝文件
scp src linuxidc@192.168.8.144:/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 linuxidc@192.168.8.144:/home/linuxidc/mydisk/buffer_scp_file
linuxidc@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]#
到远程主机对应的目录去查看
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 linuxidc@192.168.8.144:/home/linuxidc/mydisk/buffer_scp_file/demo.txt /mydisk/
linuxidc@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
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
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-10/108343.htm