很多时候我们都要进行一些大文件的传输,比如数据的备份,迁移等等。 下面介绍几种简单的快速传输文件的方法,希望对大家有帮助。
环境
1 | host1:192.168.1.101 |
使用scp
将host1中的file.tar.gz拷贝到host2的/tmp目录
1 | scp file.tar.gz [email protected]:/tmp |
将host1中的/root目录整个拷贝到host2的/tmp目录下(参数:-r 递归的复制整个文件夹)
1 | scp -r /root [email protected]:/tmp |
拷贝文件夹内容里的所有内容
1 | scp -r /root/* [email protected]:/tmp |
使用rsync
通过ssh通道将host1上的目录/etc备份到host2的/tmp目录 在host2执行以下指令:
1 | rsync -av -e ssh file.tar.gz 192.168.1.101:/etc /tmp |
加上- -progress可以观察传输进度
使用nc
将file.tar.gz从host2拷贝到host1:
1 | host1:nc -l 444 >file.tar.gz #先启用监听 |
将目录/etc从host2拷贝到host1:
1 | host1:nc -l 123 |tar zxvf - #先启用监听 |