SFTP(Secure File Transfer Protocol)安全的文件传输协议的使用

概述:

SFTP是Secure File Transfer Protocol的缩写,即安全的文件传输协议端口号默认为22,相比较FTP,SFTP可以为传输文件提供一种安全的加密方法,由于这种传输方式使用了加密/解密技术,所以传输效率比普通的FTP要低得多,如果您对网络安全性要求更高时,可以使用SFTP代替FTP。


使用及样例:

1、连接方法 sftp [user@]host [port] 输入密码后出现连接成功的提示符
[d:\~]$ sftp alen@192.168.56.1 1023  连接SFTP


Connecting to 192.168.56.1:1023...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Your current local directory is
D:\Documents and Settings\Alen.Liu\Documents\NetSarang\Xshell\Sessions

Type `help' to browse available commnands.
sftp:/home/alen> 
2、查看帮助,得到该工具的命令
sftp:/home/alen> help  --->查看帮助,如果查看某一个具体的命令的帮助信息,可以使用help 命令
bye     finish your SFTP session
cd      change your remote working directory
clear   clear screen
exit    finish your SFTP session
explore explore your local directory
get     download a file from the server to your local machine
help    give help
lcd     change and/or print local working directory
lls     list contents of a local directory
lpwd    print your local working directory
ls      list contents of a remote directory
mkdir   create a directory on the remote server
mv      move or rename a file on the remote server
put     upload a file from your local machine to the server
pwd     print your remote working directory
quit    finish your SFTP session
rename  move or rename a file on the remote server
rm      delete a file
rmdir   remove a directory on the remote server
sftp:/home/alen> 
其中,指令前带有l的命令,表示是对本地的操作,其他的则是对远端的操作。该工具的命令相对简单,故不对每一个命令举例,具体可以自己研究。
sftp:/home/alen> lls             --->列出本地文件列表
04/07/2017 08:39?    <DIR>              .
04/07/2017 08:39?    <DIR>              ..
04/07/2017 08:39?                    6  file.txt
04/07/2017 08:39?                 9224  mysql57-community-release-el7-9.noarch.rpm
sftp:/home/alen> put mysql57-community-release-el7-9.noarch.rpm .    --->上传本地文件到远端目录
sftp: cannot open e:\userdata to read
Uploading mysql57-community-release-el7-9.noarch.rpm to remote:/home/alen/mysql57-community-release-el7-9.noarch.rpm
sftp: sent 9.00 KB in 0.05 seconds
sftp:/home/alen> ls   --->列出远端目录下文件列表
drwx------   20 alen     alen         4096 Apr  7 16:41 .
drwxr-xr-x    5 root     root           38 Mar 29 16:30 ..
drwxr-xr-x    5 alen     alen           51 Dec 12 14:38 .mozilla
-rw-r--r--    1 alen     alen           18 Mar  6  2015 .bash_logout
-rw-r--r--    1 alen     alen          193 Mar  6  2015 .bash_profile
-rw-r--r--    1 alen     alen          231 Mar  6  2015 .bashrc
drwxr-xr-x   16 alen     alen         4096 Apr  6 15:26 .config
drwx------   10 alen     alen         4096 Dec 12 14:47 .cache
drwxr-xr-x    2 alen     alen           54 Dec 15 17:40 Desktop
drwxr-xr-x    2 alen     alen            6 Dec 12 14:37 Downloads
drwxr-xr-x    2 alen     alen            6 Dec 12 14:37 Templates
drwxr-xr-x    2 alen     alen            6 Dec 12 14:37 Public
drwxr-xr-x    2 alen     alen            6 Dec 12 14:37 Documents
drwxr-xr-x    2 alen     alen            6 Dec 12 14:37 Music
drwxr-xr-x    2 alen     alen            6 Dec 12 14:37 Pictures
drwxr-xr-x    2 alen     alen            6 Dec 12 14:37 Videos
-rw-------    1 alen     alen         1864 Apr  6 14:54 .ICEauthority
drwx------    3 alen     alen           18 Dec 12 14:37 .local
-rw-------    1 alen     alen           16 Dec 12 14:37 .esd_auth
drwx------    3 alen     alen           19 Dec 12 14:38 .gnome2
drwx------    2 alen     alen            6 Dec 12 14:38 .gnome2_private
-rw-------    1 alen     alen         6532 Apr  7 11:08 .bash_history
drwxrwxr-x    2 alen     alen           87 Mar 27 17:15 test
drwxrwxr-x    2 alen     alen           18 Mar 24 16:53 test1
drwxrwxr-x    2 alen     alen          100 Mar 27 17:13 test11
-rw-------    1 alen     alen         4408 Apr  6 14:49 .viminfo
-rw-rw-r--    1 alen     alen          178 Mar 31 15:52 file.tar.gz
drwxrwxr-x    2 alen     alen           55 Apr  1 16:05 bash
-rw-rw-r--    1 alen     alen         9224 Apr  7 16:41 mysql57-community-release-el7-9.noarch.rpm  --->在这里可以看到上面上传的文件
sftp:/home/alen> 



posted @ 2017-04-07 16:18  追梦男生  阅读(1198)  评论(0编辑  收藏  举报