网络间文件传输简析



网络间文件传输简析
 
Linux与Linux之间的文件传输
在Linux与Linux之间传输文件,最常用、最方便的是使用scp命令:
scp file username@hostIP:目录  例如:
scp aaa.txt liubin@192.168.0.100:/home/aaa.txt
 
Windows与Linux之间的文件传输
需要在Windows系统中下载PSCP.exe文件,PSCP是Putty安装包http://download.csdn.net/detail/shenzhen_liubin/4489635所带的远程文件传输工具,使用与scp命令相似:
在Putty的解压目录下(或将Putty解压目录加入Path的环境变量),在命令行窗口使用pscp命令:
C:\Users\william.liub>pscp
PuTTY Secure Copy client
Release 0.62  www.2cto.com  
Usage: pscp [options] [user@]host:source target
       pscp [options] source [source...] [user@]host:target
       pscp [options] -ls [user@]host:filespec
Options:
  -V        print version information and exit
  -pgpfp    print PGP key fingerprints and exit
  -p        preserve file attributes
  -q        quiet, don't show statistics
  -r        copy directories recursively
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -P port   connect to specified port
  -l user   connect with specified username
  -pw passw login with specified password
  -1 -2     force use of particular SSH protocol version
  -4 -6     force use of IPv4 or IPv6
 
  -C        enable compression
  -i key    private key file for authentication
  -noagent  disable use of Pageant
  -agent    enable use of Pageant
  -batch    disable all interactive prompts
  -unsafe   allow server-side wildcards (DANGEROUS)
  -sftp     force use of SFTP protocol
  -scp      force use of SCP protocol
  www.2cto.com  
pscp file username@hostIP:目录  例如:
pscp abc.txt liubin@192.186.0.100:/home/abc.txt 该命令即为将windows系统中当前目录的abc.txt文件copy到192.168.0.1机器的home目录下面,使用该命令会要求输入192.186.0.100机器中用户名为liubin的密码;也可以使用-l参数明确用户名,如下:
pscp -l liubin abc.txt 192.186.0.100:/home/abc.txt 注意: -l 参数需要紧跟pscp命令,该命令同上诉命令效果相同
 
pscp命令还可以使用-r参数copy文件夹到远程机器,使用方式:
pscp -r dir username@192.168.0.10:目录
 
同样pscp命令能够将Linux机器上的文件或文件夹copy到windows上,只需要交互源和目标即可,如下:
pscp username@hostIP:目录\file file 例如:
pscp liubin@192.168.0.1:home\abc.txt . 该命令将192.168.0.100机器中/home目录下面的abc.txt文件copy到windows的当前目录;
pscp命令同样可以将Linux机器上的文件夹copy到windows上,同样使用-r参数:
pscp -r liubin@192.168.0.1:home\dir .  该命令将192.168.0.100机器中/home目录下面的dir文件夹copy到windows的当前目录;
  www.2cto.com  
使用SCFTP工具进行Windows和Linux之间的文件传输
SCTFP工具同样是Putty安装包中的工具,该工具可以建立windows和Linux之间的FTP通道,通过scftp hostIP 命令打开windows和Linux之间的链接,如:
scftp 192.168.0.1
输入服务器的用户名和密码即可。
 
通过 pwd和lpwd命令可以分别查看远程服务器和本地的当前工作目录;
使用cd和lcd命令能够分别切换远程和本地的当前工作目录;
ls或dir命令可以列出远程当前工作目录下面的文件列表;
!dir命令可以列出本地当前工作目录的列表;
使用get/put命令可以分别下载和上传文件,例如:
get file 从远处服务的当前工作目录下载file文件到本地当前目录;
put file 则是将本地当前目录下的file文件上传到远程服务器的当前工作目录下;
如需下载和上传文件夹,需使用-r参数,如:
get -r dir 和 put -r dir
更详细的SCTP命令可以是help命令进行查看。
 
 
作者 shenzhen_liubin

相关内容

    暂无相关文章