使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件
景:
方案:


SFTP命令

sftp> help Available commands: ascii Set transfer mode to ASCII binary Set transfer mode to binary cd path Change remote directory to 'path' lcd path Change local directory to 'path' detail remote-path Display system information about remote file or folder ldetail local-path Display system information about local file or folder chgrp group path Change group of file 'path' to 'group' chmod mode path Change permissions of file 'path' to 'mode' chown owner path Change owner of file 'path' to 'owner' exit Quit sftp help Display this help text include filename Include commands from 'filename' Alternate: < filename get [-r][-a | -b] remote-path Download file -r downloads directory recursively force ascii (-a) or binary (-b) mode ln [-s] existingpath linkpath Hardlink / symlink remote file ls [options] [path] Display remote directory listing lls [options] [path] Display local directory listing mkdir path Create remote directory lmkdir path Create local directory mv oldpath newpath Move remote file lmv oldpath newpath Move local file open [user@]host[:port] Connect to remote host put [-r][-a | -b] local-path Upload file -r uploads directory recursively force ascii (-a) or binary (-b) mode pwd Display remote working directory lpwd Print local working directory quit Quit sftp rename oldname newname Rename remote file lrename oldname newname Rename local file rmdir path Remove remote directory lrmdir path Remove local directory rm path Delete remote file lrm path Delete local file su username Substitutes the current user This is only supported with VShell for Windows 3.5 or later. type [transfer-mode] Display or set file transfer mode view remote-path Download and open file version Display protocol version

翻译一下就是:

sftp-- 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 显示协议版本

我们主要用到的就是一下六个命令

cd 路径 更改远程目录到“路径” lcd 路径 更改本地目录到“路径” ls [选项] [路径] 显示远程目录列表 lls [选项] [路径] 显示本地目录列表 put 本地路径 上传文件 get 远程路径 下载文件

这里在详细说明一下远程目录和本地目录。
远程目录:ls查看到的是ubuntu虚拟机上面的目录
本地目录:lls查看到的是windows实体机上面的目录。
实例:
假设我需要实现windows下的e:\sftp\test1.txt和ubuntu下/home/enadmin/test2.txt的互换,可以进行一下操作:
put操作:windows->linux
查看目录权限

root@BJCGNMON01:/home# ll total 20 drwxr-xr-x 5 root root 4096 Apr 18 15:21 ./ drwxr-xr-x 24 root root 4096 Jan 3 14:14 ../ drwxr-xr-x 9 enadmin enadmin 4096 Apr 18 15:22 enadmin/ drwxr-xr-x 2 root root 4096 Apr 18 15:21 sftp/--可以看到sftp的权限是root的 drwxr-xr-x 2 root root 4096 Apr 18 14:57 test/ root@BJCGNMON01:/home# chown -R enadmin.enadmin sftp/ root@BJCGNMON01:/home# ll total 20 drwxr-xr-x 5 root root 4096 Apr 18 15:21 ./ drwxr-xr-x 24 root root 4096 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 root root 4096 Apr 18 14:57 test/

拷贝文件

sftp> put test* --初始想将文件从windows系统put到ubuntu系统,发现失败,提示拒绝访问 Uploading test1.txt to /home/test1.txt put: failed to upload e:/sftp/test1.txt. 拒绝访问。 Uploading test2.txt to /home/test2.txt put: failed to upload e:/sftp/test2.txt. 拒绝访问。 Uploading test3.txt to /home/test3.txt put: failed to upload e:/sftp/test3.txt. 拒绝访问。 sftp> pwd --查看当前目录是/home目录,权限是root的 /home sftp> cd /home/enadmin/ --我切换到enadmin目录下 sftp> ls Graphs.pm msmtp ntp sent smokeping.tar.gz smokepingrtt.tar.gz smokepingrtt2.tar.gz Target wqy wqy-zenhei-0.8.38-1.deb sftp> lls test1.txt test2.txt test3.txt sftp> 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> ls sftp> lls test1.txt test2.txt test3.txt sftp> 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/enadmin sftp> lpwd e:/Documents sftp> lcd e:/sftp --切换目录 sftp> lls rc.local test1.txt test2.txt test3.txt sftp> ls Graphs.pm msmtp ntp sent smokeping.tar.gz smokepingrtt.tar.gz smokepingrtt2.tar.gz Target test1.txt test2.txt test3.txt wqy wqy-zenhei-0.8.38-1.deb sftp> get Graphs.pm --下载文件到windows Downloading 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.txt test2.txt test3.txt sftp>

使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件的更多相关文章
- SecureCRT的SFTP在Windows与Linux之间传输文件
使用SecureCRT软件ssh连接到Linux虚拟机.然后在SecureCRT上面打开SFTP会话
- 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件(转载)
参考文献: http://ice-k.iteye.com/blog/1068275 http://www.cnblogs.com/chen1987lei/archive/2010/11/26/1888 ...
- 如何使用xftp工具在Windows与Linux之间传输文件
如何使用xftp工具在Windows与Linux之间传输文件 整理者:vashon 声明:感谢开源社区 xftp工具是一款SFTP,FTP文件传输软件,可在Windows pc与Unix/Linux之 ...
- 通过SSH实现Windows与linux之间传输文件
Linux是非常好的开发环境,但很多时候我们希望能够在Windows上操作,通过SSH协议可以实现两者之间传输文件. 一 需要在Linux系统上安装ssh-server,有的linux系统自带了. 查 ...
- 用rz,sz命令在windows和linux之间传输文件(转)
转自http://www.linuxmine.com/178.html有很多人没有听说过ZModem协议,更不知道有rz/sz这样方便的工具: 下面一段是从SecureCRT的帮助中copy的: ZM ...
- Windows、Linux之间传输文件的几种方式
常见的文件传输协议有ftp.sftp,sftp就是在ftp的基础上对传输的数据进行了加密. ftp速度快,sftp速度略慢但安全性高. ftp默认使用21端口,sftp默认使用22端口. 我使用的是C ...
- 利用SSH secure Shell实现windows与linux之间传输文件
在windows下安装SSH secure Shell.默认安装后有两个快捷方式. linux下需要安装openssh-server utuntu默认安装了opens是-client,所以不需要安装, ...
- windows与linux之间传输文件
1.使用SSH Secure Shell Client 百度网盘 下载地址 http://pan.baidu.com/s/1kTmp00J 2.使用pscp 百度网盘地址:http://pan.bai ...
- linux CentOS 安装rz和sz命令 lrzsz 实现windows和linux之间的文件上传 下载
https://blog.nbhao.org/1902.html https://bbs.csdn.net/topics/391989523 https://www.cnblogs.com/zhoul ...
随机推荐
- 向jboss写入服务器日志
实际开发中,记录日志是常用的功能,jboss默认情况下已经记录了很多运行日志,如果开发人员要手动在server.log中写入日志,可以参考下面的方法: package utils; import ja ...
- TinyFrame开篇:基于CodeFirst的ORM
前言 做项目的这段时间,由于比较忙,一直没有机会闲下来思考.正好趁目前手头活儿轻松点,就花了一两天时间搭建了一个比较简单的框架,名称暂时就叫做:TinyFrame吧.顾名思义,就是微框架的意思.虽然这 ...
- lecture14-RBM的堆叠、修改以及DBN的决策学习和微调
这是Hinton的第14课,主要介绍了RBM和DBN的东西,这一课的课外读物有三篇论文<Self-taught learning- transfer learning from unlabele ...
- 深入理解OOP(第一天):多态和继承(初期绑定和编译时多态)
在本系列中,我们以CodeProject上比较火的OOP系列博客为主,进行OOP深入浅出展现. 无论作为软件设计的高手.或者菜鸟,对于架构设计而言,均需要多次重构.取舍,以有利于整个软件项目的健康构建 ...
- 无法将分支 master 发布到远程 origin,因为远程存储库中已存在具有同一名称的分支
无法将分支 master 发布到远程 origin,因为远程存储库中已存在具有同一名称的分支.发布此分支将导致远程存储库中的分支发生非快进更新. 第一次用oschina的git设置完远程仓库后提交出现 ...
- (404) 未找到 获取StatusCode状态码
异常代码: (HttpWebResponse)req.GetResponse(); 当执行这段代码出现异常 解决问题 那如果我们想获得错误发生时候服务器段错误页面的源代码该如何做呢? 其实非常非常简单 ...
- SDRAM操作原理分析
芯片原理图 引脚原理图 指令 通过对上面指令的总结,简化出要用到的指令如下: 指令 常量名 CKE CSn RAS CASn WEn 备注 空操作 NOP 1 0 1 1 1 行激活 ACTIVE ...
- apache 多端口配置和虚拟主机配置
1 打开httpd.conf文件 2 添加端口监听 (找到Lisen 80 在后面添加 Listen 端口号 如Listen 1112) port =>你的端口 project_name=> ...
- iOS-- pod常用命令
- java 常用的一些关键字
1.关键字extends 1.继承作用 优化代码,减少代码的重复使用. 2.继承使用时机 两个类之间必须要满足is a的关系 ,才能够拥有继承关系,不是任 何 情况下都允许继承 3.继承的使用注意事项 ...