S3500-EA系列交换机作为SFTP客户端功能的配置
一、 组网需求:
Switch A和Switch B之间建立SSH连接,Switch A作为SFTP客户端登录到Switch B,进行文件管理和文件传送等操作。SSH用户采用的认证方式为publickey认证,认证时采用的公共密钥算法为RSA。
二、 组网图:
三、 配置步骤:
(1)配置服务器端Switch B
# 生成RSA及DSA密钥对,并启动SSH服务器。
<SwitchB> system-view
[SwitchB] public-key local create rsa
[SwitchB] public-key local create dsa
[SwitchB] ssh server enable
# 启动SFTP服务器。
[SwitchB] sftp server enable
# 配置VLAN接口1的IP地址,客户端将通过该地址连接SSH服务器。
[SwitchB] interface vlan-interface 1
[SwitchB-Vlan-interface1] ip address 192.168.0.1 255.255.255.0
[SwitchB-Vlan-interface1] quit
# 设置SSH客户端登录用户界面的认证方式为AAA认证。
[SwitchB] user-interface vty 0 4
[SwitchB-ui-vty0-4] authentication-mode scheme
# 设置Switch B上远程用户登录协议为SSH。
[SwitchB-ui-vty0-4] protocol inbound ssh
[SwitchB-ui-vty0-4] quit
# 从文件pubkey中导入远端的公钥。
[SwitchB] public-key peer Switch001 import sshkey pubkey
# 设置SSH用户client001的服务类型为SFTP,认证方式为publickey,并指定公钥为Switch001,工作目录为cf:/。
[SwitchB] ssh user client001 service-type sftp authentication-type publickey
assign publickey Switch001 work-directory cf:/
(2)配置客户端Switch A
# 配置VLAN接口1的IP地址。
<SwitchA> system-view
[SwitchA] interface vlan-interface 1
[SwitchA-Vlan-interface1] ip address 192.168.0.2 255.255.255.0
[SwitchA-Vlan-interface1] quit
# 生成RSA密钥对。
[SwitchA] public-key local create rsa
# 将生成的RSA主机公钥导出到指定文件pubkey中。
[SwitchA] public-key local export rsa ssh2 pubkey
[SwitchA] quit
# 与远程SFTP服务器建立连接,进入SFTP Client视图。
<SwitchA> sftp 192.168.0.1
Input Username: client001
Trying 192.168.0.1 ...
Press CTRL+K to abort
Connected to 192.168.0.1 ...
The Server is not authenticated. Continue? [Y/N]:y
Do you want to save the server public key? [Y/N]:n
sftp-client>
# 显示服务器的当前目录,删除文件z,并检查此目录是否删除成功。
sftp-client> dir
-rwxrwxrwx 1 noone nogroup 1759 Aug 23 06:52 config.cfg
-rwxrwxrwx 1 noone nogroup 225 Aug 24 08:01 pubkey2
-rwxrwxrwx 1 noone nogroup 283 Aug 24 07:39 pubkey1
drwxrwxrwx 1 noone nogroup 0 Sep 01 06:22 new
-rwxrwxrwx 1 noone nogroup 225 Sep 01 06:55 pub
-rwxrwxrwx 1 noone nogroup 0 Sep 01 08:00 z
sftp-client> delete z
The following files will be deleted:
/z
Are you sure to delete it? [Y/N]:y
This operation may take a long time.Please wait...
File successfully Removed
sftp-client> dir
-rwxrwxrwx 1 noone nogroup 1759 Aug 23 06:52 config.cfg
-rwxrwxrwx 1 noone nogroup 225 Aug 24 08:01 pubkey2
-rwxrwxrwx 1 noone nogroup 283 Aug 24 07:39 pubkey1
drwxrwxrwx 1 noone nogroup 0 Sep 01 06:22 new
-rwxrwxrwx 1 noone nogroup 225 Sep 01 06:55 pub
# 新增目录new1,并检查新目录是否创建成功。
sftp-client> mkdir new1
Success
New directory created
sftp-client> dir
-rwxrwxrwx 1 noone nogroup 1759 Aug 23 06:52 config.cfg
-rwxrwxrwx 1 noone nogroup 225 Aug 24 08:01 pubkey2
-rwxrwxrwx 1 noone nogroup 283 Aug 24 07:39 pubkey1
drwxrwxrwx 1 noone nogroup 0 Sep 01 06:22 new
-rwxrwxrwx 1 noone nogroup 225 Sep 01 06:55 pub
drwxrwxrwx 1 noone nogroup 0 Sep 02 06:30 new1
# 将目录名new1更名为new2,并查看是否更名成功。
sftp-client> rename new1 new2
Success
File successfully renamed
sftp-client> dir
-rwxrwxrwx 1 noone nogroup 1759 Aug 23 06:52 config.cfg
-rwxrwxrwx 1 noone nogroup 225 Aug 24 08:01 pubkey2
-rwxrwxrwx 1 noone nogroup 283 Aug 24 07:39 pubkey1
drwxrwxrwx 1 noone nogroup 0 Sep 01 06:22 new
-rwxrwxrwx 1 noone nogroup 225 Sep 01 06:55 pub
drwxrwxrwx 1 noone nogroup 0 Sep 02 06:33 new2
# 从服务器上下载文件pubkey2到本地,并更名为public。
sftp-client> get pubkey2 public
Remote file:/pubkey2 ---> Local file: public
Downloading file successfully ended
# 将本地文件pu上传到服务器上,更名为puk,并查看上传是否成功。
sftp-client> put pu puk
Local file:pu ---> Remote file: /puk
Uploading file successfully ended
sftp-client> dir
-rwxrwxrwx 1 noone nogroup 1759 Aug 23 06:52 config.cfg
-rwxrwxrwx 1 noone nogroup 225 Aug 24 08:01 pubkey2
-rwxrwxrwx 1 noone nogroup 283 Aug 24 07:39 pubkey1
drwxrwxrwx 1 noone nogroup 0 Sep 01 06:22 new
drwxrwxrwx 1 noone nogroup 0 Sep 02 06:33 new2
-rwxrwxrwx 1 noone nogroup 283 Sep 02 06:35 pub
-rwxrwxrwx 1 noone nogroup 283 Sep 02 06:36 puk
sftp-client>
# 退出SFTP。
sftp-client> quit
Bye
Connection closed.
<SwitchA>
四、 配置关键点:
(1)SSH用户的服务类型设置为sftp或者all。
(2)S3500-EA系列以太网交换机的软件版本只支持RSA密钥对。
该案例暂时没有网友评论
✖
案例意见反馈
亲~登录后才可以操作哦!
确定你的邮箱还未认证,请认证邮箱或绑定手机后进行当前操作