XShell⼯具sftp使⽤【转】
sftp是Secure File TransferProtocol的缩写,安全⽂件传送协议。可以为传输⽂件提供⼀种安全的加密⽅法。sftp与 ftp有着⼏乎⼀样的语法和功能。SFTP为 SSH的⼀部分,是⼀种传输档案⾄Blogger伺服器的安全⽅式。其实在SSH软件包中,已经包含了⼀个叫作SFTP(Secure File Transfer Protocol)的安全⽂件传输⼦系统,SFTP本⾝没有单独的守护进程,它必须使⽤sshd守护进程(端⼝号默认是22)来完成相应的连接操作,所以从某种意义上来说,SFTP并不像⼀个服务器程序,⽽更像是⼀个客户端程序。SFTP同样是使⽤加密传输认证信息和传输的数据,所以,使⽤SFTP是⾮常安全的。但是,由于这种传输⽅式使⽤了加密/解密技术,所以传输效率⽐普通的FTP要低得多,如果您对⽹络安全性要求更⾼时,可以使⽤SFTP代替FTP。
⼀、连接⽅式
常⽤的⽅式有两种,⼀种直接采⽤sftp连接远端服务器IP
另⼀种则先登录远程服务器,在开启sftp功能
1、sftp [remotehost IP ]
通过sftp连接[host],端⼝为默认的22,⽤户为Linux当前登录⽤户。
Xshell 5 (Build 0806)
Copyright (c) 2002-2015 NetSarang Computer, Inc. All rights reserved.
Type `help' to learn how to use Xshell prompt.
[c:\~]$ sftp192.168.56.101
Connecting to 192.168.56.
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Your current local directory is
C:\Users\FieldYang\Documents\NetSarang\Xshell\Sessions
Type `help' to browse available commnands.
sftp:/root>
2、sftp -oPort=[port][remotehost IP]
通过sftp连接远程服务器,指定端⼝[port],⽤户为Linux当前登录⽤户。
3、sftp[user]@[remotehost IP]
通过sftp连接远程服务器,端⼝为默认的22,指定⽤户[user]。
Xshell 5 (Build 0806)
Copyright (c) 2002-2015 NetSarang Computer,Inc. All rights reserved.
Type `help' to learn how to use Xshell prompt.
[c:\~]$*********************.56.101
Connecting to 192.168.56.
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Your current local directory is
C:\Users\FieldYang\Documents\NetSarang\Xshell\Sessions
Type `help' to browse available commnands.
sftp:/home/fieldyang>
4、sftp -oPort=[port][user]@[ remotehost IP]
通过sftp连接[remotehost IP],端⼝为[port],⽤户为[user]。
5、通过Xshell5与linux建⽴连接后,在图形⽤户⾯板上 窗⼝->传输新建⽂件,打开xftp的字符界⾯,如图,直接关闭即可打开⼀个sftp窗⼝
⼆、⽤法
1、基本⽤法
sftp:/root> help
bye finish your SFTP session
退出sftp
cd change your remote workingdirectory
更改远程服务器⼯作⽬录
clear clear screen
清屏
exit finish your SFTP session
explore explore your local directory
导⼊本地⽬录
get download a file from theserver to your local machine
从远程服务器上下载⽂件到本机
help give help
查帮助
lcd change and/or print localworking directory
切换本地当前⼯作⽬录
lls list contents of a localdirectory
列出本地当前⽬录的内容
lpwd print your local workingdirectory
打印当前⼯作⽬录
ls list contents of a remotedirectory
列出远程服务器⽬录内容
mkdir create a directory on theremote server
在远程服务器上创建⼀个⽬录
mv move or rename a file onthe remote server
搬移或重命名⼀个的远程服务器⽂件
put upload a file from yourlocal machine to the server 将本机的⽂件上传到远程服务器
pwd print your remote workingdirectory
打印远程服务器⼯作路径
quit finish your SFTP session
退出
rename move or rename a file onthe remote server
搬移或重命名⼀个的远程服务器⽂件
rm delete a file
删除⼀个⽂件
rmdir remove a directory on theremote server
在远程服务器上删除⼀个⽬录删除⼀个⽬录
2、常⽤的为上传下载
1)、get
从远程服务器上下载⼀个⽂件存放到本地,如下:
先通过lcd切换到本地那个⽬录下,然后通过get file
>> lcd d:\ #表⽰切换到本地的d盘下
>> get ./test.sql #这样就将当前⽂件下载本地的d盘下
2)、put
是将本地的⽂件上传到远程服务器上,如下:
>> put #在windows下弹出选择⽂件的窗⼝
3)、lcd
先通过lcd切换到本地那个⽬录下
>> lcd c:\ #表⽰切换到本地的c盘下
4)、lls
#显⽰当前⽬录下的所有⽂件
5)、pwd
#显⽰当前⽬录
三、各个⽤法实例详解
实例1、从服务器下载⽂件到本机
Xshell 5 (Build 0806)
Copyright (c) 2002-2015NetSarang Computer, Inc. All rights reserved.
Type `help' to learn howto use Xshell prompt.
[c:\~]$
Connecting to192.168.56.
Connection established.
To escape to local shell,press 'Ctrl+Alt+]'.
Your current localdirectory is
C:\Users\FieldYang\Documents\NetSarang\Xshell\Sessions
Type `help' to browseavailable commnands.
sftp:/root> cd /mnt/share
#远程路径切换为/mnt/share
sftp:/mnt/share> ls –lt
drwxrwxrwx 1 1000 users 4096 Jun 16 13:39 .
drwxr-xr-x 7 root root 4096 Jun 15 14:06 ..
-rwxrwxrwx 1 1000 users 220151 Jun 15 utputstream-ZHJ8IY
-rwxrwxrwx 1 1000 users 19362 Jun 16 12:270.jpg
-rwxrwxrwx 1 1000 users 16157 Jun 16 13:39Auth Server and SOAP proxy.docx
-rwxrwxrwx 1 1000 users 63952 Jun 16 12:29bamquickinstall.pdf
xshell下载-rwxrwxrwx 1 1000 users 7277 Jun 16
-rwxrwxrwx 1 1000 users 7277 May 12
-rwxrwxrwx 1 1000 users 111395 Jun 15 15:46libpcap-0.9.4-15.el5.x86_64.rpm
-rwxrwxrwx 1 1000 users 363677 Jun 15 14:59ppp-2.4.4-14.1.rhel5.x86_64.rpm
-rwxrwxrwx 1 1000 users 48430 Jun 15 14:57ppp-devel-2.4.4-14.1.rhel5.x86_64.rpm
-
rwxrwxrwx 1 1000 users 86211 Jun 15 15:38pptpd-1.4.0-1.rhel4.x86_64.rpm
-rwxrwxrwx 1 1000 users 86509 Jun 15 14:46pptpd-1.4.0-1.rhel5.x86_64.rpm
-rwxrwxrwx 1 1000 users 220151 Jun 15 13:22Screenshot.png
-rwxrwxrwx 1 1000 users 21789 Jun 16 13:39Traffic Usage System alarm handling - Gateway, RadiusGWProxy, RadiusProxyServer.docx
sftp:/mnt/share> lcd d:\Field\test_sftp
#切换到本地的d盘下Field⽂件夹的test_sftp⽂件夹
Local directory is nowd:\Field\test_sftp
sftp:/mnt/share> lpwd
Local directory isd:\Field\test_sftp
#打印本地⽂件夹路径
sftp:/mnt/share> lls
06/16/2016 05:44¤W <DIR> .
06/16/2016 05:44¤W <DIR> ..
#查看本地⽂件夹d:\Field\test_sftp内容
sftp:/mnt/share>get ./0.jpg .//pptpd-1.4.0-1.rhel5.x86_64.rpm
#下载远程服务器/mnt/share上的0.jpg、、#pptpd-1.4.0-1.rhel5.x86_64.rpm到本地⽂件夹d:\Field\test_sftp中
Fetching/mnt/share/./pptpd-1.4.0-1.rhel5.x86_64.rpm to pptpd-1.4.0-1.rhel5.x86_64.rpm
sftp: received 84.4 KB in0.64 seconds
Fetching/mnt/share/./
sftp: received 7.10 KB in0.02 seconds
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论