首先要确保两台机子直接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$
以上是本机传文件到远程主机,下面再来试试从远程主机拷贝文件到本机