使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
来源:互联网 发布:linux 打印目录树 编辑:程序博客网 时间:2024/05/01 00:07
使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
参考文献:
http://ice-k.iteye.com/blog/1068275
http://www.cnblogs.com/chen1987lei/archive/2010/11/26/1888391.html
背景:
有一台主机,安装了windows7,在其安装了virtualbox,然后安装了ubuntu虚拟机。在windows7上安装SecureCRT来ssh连接ubuntu虚拟机。一般在windows上面下载软件,然后通过vsftp上传到ubuntu虚拟机上。但是这样非常麻烦,现在考虑使用sftp协议来直接传输。
方案:
使用SecureCRT软件ssh连接到ubuntu虚拟机。然后在SecureCRT上面打开SFTP会话,如下图所示:
SFTP命令
进入到sftp命令窗口以后,就可以通过sftp命令来进行文件互传的操作。下面主要介绍一下sftp命令的含义。
sftp> helpAvailable commands:ascii Set transfer mode to ASCIIbinary Set transfer mode to binarycd pathChange remote directory to 'path'lcd path Change local directory to 'path'detail remote-path Display system information about remote file or folderldetail local-path Display system information about local file or folderchgrp group path Change group of file 'path' to 'group'chmod mode pathChange permissions of file 'path' to 'mode'chown owner path Change owner of file 'path' to 'owner'exit Quit sftphelp Display this help textinclude filename Include commands from 'filename' Alternate: < filenameget [-r][-a | -b] remote-path Download file -r downloads directory recursively force ascii (-a) or binary (-b) modeln [-s] existingpath linkpath Hardlink / symlink remote filels [options] [path]Display remote directory listinglls [options] [path] Display local directory listingmkdir path Create remote directorylmkdir pathCreate local directorymv oldpath newpath Move remote filelmv oldpath newpathMove local fileopen [user@]host[:port]Connect to remote hostput [-r][-a | -b] local-path Upload file -r uploads directory recursively force ascii (-a) or binary (-b) modepwdDisplay remote working directorylpwd Print local working directoryquit Quit sftprename oldname newname Rename remote filelrename oldname newnameRename local filermdir path Remove remote directorylrmdir pathRemove local directoryrm pathDelete remote filelrm path Delete local filesu usernameSubstitutes the current user This is only supported with VShell for Windows 3.5 or later.type [transfer-mode] Display or set file transfer modeview remote-path Download and open fileversionDisplay protocol versionsftp-- help 可用命令: cd 路径更改远程目录到“路径” lcd 路径 更改本地目录到“路径” chgrp group path 将文件“path”的组更改为“group” chmod mode path将文件“path”的权限更改为“mode” chown owner path 将文件“path”的属主更改为“owner” exit 退出 sftp help 显示这个帮助文本 get 远程路径 下载文件 ln existingpath linkpath 符号链接远程文件 ls [选项] [路径] 显示远程目录列表 lls [选项] [路径] 显示本地目录列表 mkdir 路径 创建远程目录 lmkdir 路径创建本地目录 mv oldpath newpath 移动远程文件 open [用户@]主机[:端口]连接到远程主机 put 本地路径 上传文件 pwd显示远程工作目录 lpwd 打印本地工作目录 quit 退出 sftp rmdir 路径 移除远程目录 lrmdir 路径移除本地目录 rm 路径删除远程文件 lrm 路径 删除本地文件 symlink existingpath linkpath 符号链接远程文件 version显示协议版本
这里在详细说明一下远程目录和本地目录。
远程目录:ls查看到的是ubuntu虚拟机上面的目录
本地目录:lls查看到的是windows实体机上面的目录。
实例:
假设我需要实现windows下的e:\sftp\test1.txt和ubuntu下/home/enadmin/test2.txt的互换,可以进行一下操作:
put操作:windows->linux
查看目录权限
root@BJCGNMON01:/home# lltotal 20drwxr-xr-x 5 rootroot4096 Apr 18 15:21 ./drwxr-xr-x 24 rootroot4096 Jan 3 14:14 ../drwxr-xr-x 9 enadmin enadmin 4096 Apr 18 15:22 enadmin/drwxr-xr-x 2 rootroot4096 Apr 18 15:21 sftp/--可以看到sftp的权限是root的drwxr-xr-x 2 rootroot4096 Apr 18 14:57 test/root@BJCGNMON01:/home# chown -R enadmin.enadmin sftp/root@BJCGNMON01:/home# lltotal 20drwxr-xr-x 5 rootroot4096 Apr 18 15:21 ./drwxr-xr-x 24 rootroot4096 Jan 3 14:14 ../drwxr-xr-x 9 enadmin enadmin 4096 Apr 18 15:22 enadmin/drwxr-xr-x 2 enadmin enadmin 4096 Apr 18 15:21 sftp/--修改以后权限变成enadmin的了drwxr-xr-x 2 rootroot4096 Apr 18 14:57 test/
拷贝文件
sftp> put test* --初始想将文件从windows系统put到ubuntu系统,发现失败,提示拒绝访问Uploading test1.txt to /home/test1.txtput: failed to upload e:/sftp/test1.txt. 拒绝访问。 Uploading test2.txt to /home/test2.txtput: failed to upload e:/sftp/test2.txt. 拒绝访问。 Uploading test3.txt to /home/test3.txtput: failed to upload e:/sftp/test3.txt. 拒绝访问。 sftp> pwd --查看当前目录是/home目录,权限是root的/homesftp> cd /home/enadmin/ --我切换到enadmin目录下sftp> lsGraphs.pm msmtp ntpsent smokeping.tar.gz smokepingrtt.tar.gzsmokepingrtt2.tar.gz Targetwqywqy-zenhei-0.8.38-1.debsftp> llstest1.txt test2.txt test3.txtsftp> put test* -再次尝试将windows下的文件put到/homg/enadmin目录下,这次成功Uploading test1.txt to /home/enadmin/test1.txt 100% 4 bytes 4 bytes/s 00:00:00 e:/sftp/test1.txt: 4 bytes transferred in 0 seconds (4 bytes/s)Uploading test2.txt to /home/enadmin/test2.txt 100% 4 bytes 4 bytes/s 00:00:00 e:/sftp/test2.txt: 4 bytes transferred in 0 seconds (4 bytes/s)Uploading test3.txt to /home/enadmin/test3.txt 100% 5 bytes 5 bytes/s 00:00:00 e:/sftp/test3.txt: 5 bytes transferred in 0 seconds (5 bytes/s)sftp> cd /home/sftp/--在修改sftp目录权限以后,再次切换到sftp目录下sftp> lssftp> llstest1.txt test2.txt test3.txtsftp> put test* --这回put成功。所以跟权限相关Uploading test1.txt to /home/sftp/test1.txt 100% 4 bytes 4 bytes/s 00:00:00 e:/sftp/test1.txt: 4 bytes transferred in 0 seconds (4 bytes/s)Uploading test2.txt to /home/sftp/test2.txt 100% 4 bytes 4 bytes/s 00:00:00 e:/sftp/test2.txt: 4 bytes transferred in 0 seconds (4 bytes/s)Uploading test3.txt to /home/sftp/test3.txt 100% 5 bytes 5 bytes/s 00:00:00 e:/sftp/test3.txt: 5 bytes transferred in 0 seconds (5 bytes/s)
注意点:这里需要注意权限的问题。加入我是使用enadmin账户初始连接ubuntu的,那么我put的文件只能放到文件夹权限是enadmin的目录下,不能放到文件夹权限是root的目录下。如果想放到文件夹权限是root的目录下,那么初始就使用root账户连接ubunut,然后再创建sftp会话,这样就可以了。
get操作:linux->windows
get操作没有权限设定
sftp> pwd/home/enadminsftp> lpwde:/Documentssftp> lcd e:/sftp --切换目录sftp> llsrc.local test1.txt test2.txttest3.txtsftp> lsGraphs.pm msmtp ntpsent smokeping.tar.gz smokepingrtt.tar.gzsmokepingrtt2.tar.gz Targettest1.txttest2.txt test3.txt wqywqy-zenhei-0.8.38-1.debsftp> get Graphs.pm --下载文件到windowsDownloading Graphs.pm from /home/enadmin/Graphs.pm 100% 13KB 13KB/s 00:00:00 /home/enadmin/Graphs.pm: 13503 bytes transferred in 0 seconds (13 KB/s)sftp> lls --查看windows目录Graphs.pm rc.local test1.txttest2.txt test3.txtsftp>
- SecureCRT的SFTP在Windows与Linux之间传输文件
- 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
- 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
- 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
- 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
- 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
- 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
- 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
- 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
- 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
- 使用SecureCRT的SFTP命令行在WINDOWS与LINUX之间传输文件
- 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
- 利用securecrt在linux与windows之间传输文件
- 利用securecrt在linux与windows之间传输文件
- 利用securecrt在linux与windows之间传输文件 收藏
- 利用securecrt在linux与windows之间传输文件
- 利用SecureCRT在linux与Windows之间传输文件
- 利用SecureCRT在linux与Windows之间传输文件
- IOS常用第三方框架 --- EGOTableViewPullRefresh 下拉刷新
- poj 3009 Curling 2.0 dfs回溯
- Java的局部内部类以及final类型的参数和变量
- [转载]OpenCV如何扫描图像、利用查找表和计时
- 陈怡暖:聚焦美国二季度两大数据,现货黄金V形反转概率小
- 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
- maven web 项目运行 java main 程序 的简便方法
- JAVA IO流
- Longest Substring Without Repeating Characters
- 学习HTML+CSS
- 优酷土豆2014年校园招聘会笔试题
- 码农走向Quant之路_开源学习工具_Python_LEAN
- activity之间传值,serializable问题
- VC++开发工具快捷键大全