QQ叫紫珊 发表于 2015-11-6 01:59:13

远程传送文件命令大全(ssh ftp)

  ftp:   
  ftp ip
  > get filename
  > putfilename
  > bye
  ssh:
  传输到远程:tar czf - /path/filename | ssh server "tar zxf -"
  这样回把文件传送到登陆server上用户的根目录里。
  
  SSH PUSH(从本地发送到远程):
代码:

$ tar cvf - . | gzip -c -1 | ssh user@host "cat > remotefile.gz"
$ tar czvf - . | ssh user@host "cat > remote.tar.gz"
$ ssh target_address cat < localfile &quot;>&quot; remotefile
$ ssh target_address cat < localfile - &quot;>&quot; remotefile
$ cat localfile | ssh target_address cat &quot;>&quot; remotefile
$ cat localfile | ssh target_address cat - &quot;>&quot; remotefile
注: 以上命令行中的 大于号> 两边有双引号(&quot; &quot;) , 小于号< 两边则没有。

$ dd if=localfile | ssh target_address dd ōf=remotefile
$ ssh target_address cat <localfile &quot;|&quot; dd ōf=remotefile
$ ssh target_address cat - <localfile &quot;|&quot; dd ōf=remotefile
$ ( cd SOURCEDIR && tar cf - . ) | ssh target_address &quot;(cd DESTDIR && tar xvpf - )&quot;
$ ( cd SOURCEDIR && tar cvf - . ) | ssh target_address &quot;(cd DESTDIR && cat - > remotefile.tar )&quot;
$ ( cd SOURCEDIR && tar czvf - . ) | ssh target_address &quot;(cd DESTDIR && cat - > remotefile.tgz )&quot;
$ ( cd SOURCEDIR && tar cvf - . | gzip -1 -) | ssh target_address &quot;(cd DESTDIR && cat - > remotefile.tgz )&quot;
$ ssh target_address &quot;( nc -l -p 9210 > remotefile & )&quot; && cat source-file | gzip -1 - | nc target_address 9210
$ cat localfile | gzip -1 - | ssh target_address cat &quot;>&quot; remotefile.gz


SSH PULL(从远程获取到本地):
代码:

$ ssh target_address cat remotefile > localfile
$ ssh target_address dd if=remotefile | dd ōf=localfile
$ ssh target_address cat &quot;<&quot; remotefile > localfile
$ ssh target_address cat &quot;<&quot; remotefile.gz | gunzip >localfile


SSH COMPARE(本地和远程文件比较):
代码:

用远程计算机CPU执行比较指令
$ ssh target_address cat remotefile | diff - localfile
$ cat localfile | ssh target_address diff - remotefile

用本地计算机CPU执行比较指令
$ ssh target_address cat <localfile &quot;|&quot; diff - remotefile


注:
1、把文件压缩后再传送速度一般要比直接传送更快。
2、以上命令行中 'localfile' 和 ' remotefile' 可以是文件、目录、镜像、硬盘分区、或者硬盘驱动器( files, directories, images, hard drive partitions, or hard drives)。


FTP VIEW(从本地查看远程文件):
代码:

$ ftp> get file.gif &quot;| xv -&quot;
$ ftp> get README &quot;| more&quot;


FTP PUSH(从本地发送到远程):
代码:

$ ftp> put &quot;| tar cvf - .&quot; myfile.tar
$ ftp> put &quot;| tar cvf - . | gzip &quot; myfile.tar.gz


FTP PULL(从远程获取到本地):
代码:

$ ftp> get myfile.tar &quot;| tar xvf -&quot;
             版权声明:本文为博主原创文章,未经博主允许不得转载。
页: [1]
查看完整版本: 远程传送文件命令大全(ssh ftp)