SFTP概述
1.SFTP, 是更加安全的文件传输方式, 就是基于ssh去进行对应的加密的,传统的FTP协议,传输文件时,如果抓包能够看到文件的所有内容,甚至连用户名和密码都能看见。
2.如果你使用SFTP, 那就会进行加密传输, 提升FTP的安全性。
3.SFTP的默认端口号是22, 和ssh一样, 因为SFTP是基于ssh的,所以配置SFTP之前,先配置一下SSH,再配置SFTP。
SFTP实验
我们用两个路由器,一个充当Client,一个充当Server。
0.接口配置IP地址
两个路由器设备重命名并且接口配置IP地址,(此处省略)
<Huawei>system-view
[Huawei]sysname Client
[client]interface G0/0/0
[Client-GigabitEthernet0/0/0]ip address 192.168.1.1 24
<Huawei>system-view
[Huawei]sysname Server
[Server]interface G0/0/0
[Server-GigabitEthernet0/0/0]ip address 192.168.1.2 24
1.在aaa中创建一个用户
[Server]aaa
# 用户Bigtree 密码Huawei@123 权限15
[Server-aaa]local-user Bigtree password cipher Huawei@123 privilege level 15
Info: Add a new user.
[Server-aaa]local-user Bigtree service-type ssh # 用户Bigtree的服务类型是ssh
2.进入到远程登录的VTY虚拟类型终端,virtual Type Terminal,是逻辑接口。
[Server]user-interface vty 0 4 # 认证模式有两种 aaa和password,你要是想使用用户的方式,就选aaa # 没有配置VTY认证方式的话,设备会拒绝客户端发来的请求。 [Server-ui-vty0-4]authentication-mode aaa # 绑定ssh远程登录,这个配置完就只支持SSH,不再支持telnet,默认情况下是两个都支持 [Server-ui-vty0-4]protocol inbound ssh
3.配置SSH用户的认证方式
[Server]ssh user Bigtree authentication-type password
# SSH登录的时候,用密码登录的方式,密码就是我刚才AAA中创建的Huawei@123
4.查看设置的用户信息
[Server]display ssh user-information
Username Auth-type User-public-key-name
bigtree password null
5.开启SSH 服务器
[Server]stelnet server enable
6.查看ssh配置信息,可以看到sftp还没有打开
[Server]display ssh server status
7.Clinet第一次ssh远程登录Server
[Clinet]ssh client first-time enable [Clinet]stelnet 192.168.1.2 Please input the username:Bigtree # 输入用户名Bigtree Trying 192.168.1.2 ... Press CTRL+K to abort Connected to 192.168.1.2 ... The server is not authenticated. Continue to access it? (y/n)[n]:y # 服务器没证书,是否继续 [Clinet] Save the server's public key? (y/n)[n]:y # 保存公钥 [Clinet] Enter password: # 输入Bigtree账户的密码 <Server> # 登录到服务器
8.Server上 查看Client登录情况
[Server]display ssh server session
配置SFTP
1.第一步:服务器开启sftp服务
[Server]sftp server enable
2.第二步:给用户指定访问目录
[Server]aaa [Server-aaa]local-user Bigtree ftp-directory flash: # 指定访问目录,flash根目录,默认为空,不配置的话,sftp用户无法访问
3.第三步 最后测试
[Clinet]ssh client first-time enable [Clinet]sftp 192.168.1.2 Please input the username:BigTree # # 输入用户名Bigtree Trying 192.168.1.2 ... Press CTRL+K to abort Enter password: sftp-client>dir drwxrwxrwx 1 noone nogroup 0 Feb 21 17:29 dhcp drwxrwxrwx 1 noone nogroup 0-rwxrwxrwx 1 noone nogroup 1218 02 May 26 2014 portalpage.zip -rwxrwxrwx 1 noone nogroup 2263 Feb 21 17:29 statemach.efs -rwxrwxrwx 1 noone nogroup 828482 May 26 2014 sslvpn.zip drwxrwxrwx 1 noone nogroup 0 Feb 21 17:29 . -rwxrwxrwx 1 noone nogroup 672 Feb 21 17:29 vrpcfg.zip
# 退出 quit, 写全
sftp-client>quit
Bye